robotframework案例

举报
建帅小伙儿 发表于 2022/09/25 02:49:51 2022/09/25
【摘要】 一、公共方法 common.robot *** Settings *** Library Selenium2Library *** Keywords *** wait element [Arguments] ${LOCATOR} sleep 2 Wait Until...

一、公共方法

common.robot

*** Settings ***
Library           Selenium2Library

*** Keywords ***
wait element
    [Arguments]    ${LOCATOR}
    sleep    2
    Wait Until Element Is Visible    ${LOCATOR}
    Wait Until Element Is Enabled    ${LOCATOR}
    Wait Until Page Contains Element    ${LOCATOR}
    SLEEP    2

wait input element
    [Arguments]    ${LOCATOR}    ${INPUT_TEXT}
    wait element    ${LOCATOR}
    Input Text    ${LOCATOR}    ${INPUT_TEXT}

wait click element
    [Arguments]    ${LOCATOR}
    wait element    ${LOCATOR}
    Click Element    ${LOCATOR}

Login_Beijing
    wait input element    css=#userNameId input    gwx613100
    wait input element    css=#pwdId input    Bigdata_2013
    wait click element    css=#loginForm #buttonArea:nth-child(1) #btn_submit
    Wait Until Page Contains    Quick Start Guide
    Sleep    2

Login_retry
    Open Browser    https://console.huaweicloud.com/vpc/?region=cn-north-1&locale=en-us#/vpc/vpcmanager/dashboard    chrome
    Maximize Browser Window
    Set Window Size    1920    1080
    ${winsize}    Get Window Size
    log    ${winsize}
    Wait Until Keyword Succeeds    3x    3s    Login_Beijing

enter dashboard
    sleep    1
    go to    https://console.huaweicloud.com/vpc/?region=cn-north-1&locale=en-us#/vpc/vpcmanager/dashboard
    Wait Until Page Contains    Quick Start Guide
    sleep    2

close new select old
    Close Window
    Select Window

二、测试套-测试用例

Dashborad-All.robot

*** Settings ***
Suite Setup       Login_retry
Suite Teardown    Close Browser
Library           Selenium2Library
Resource          common.txt
Resource          VPC_Resource_Dashbord.txt

*** Test Cases ***
Dashborad-To-VPC
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-VPC

Dashborad-To-SecurityGroup
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-SecurityGroup

Dashborad-To-Network ACLs
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-Network ACLs

Dashborad-To-Eips
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-Eips

Dashborad-To-ShareBandwidth
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-ShareBandwidth

Dashborad-To-NAT Gateways
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-NAT Gateways

Dashborad-To-Elastic Load Balance
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-Elastic Load Balance

Dashborad-To-Peering Connections
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-Peering Connections

Dashborad-To-VPC Endpoints
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-VPC Endpoints

Dashborad-To-VPN Gateways
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-VPN Gateways

Dashborad-To-Direct Connections
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-Direct Connections

Dashborad-To-Cloud Connection
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-Cloud Connection

Dashborad-To-VPN Connections
    [Tags]    hec
    Wait Until Keyword Succeeds    3x    3s    Dashborad-To-VPN Connections

三、资源文件

VPC_Resource_Dashbord.robot

*** Settings ***
Library           Selenium2Library
Resource          common.txt

*** Keywords ***
Dashborad-To-VPC
    enter dashboard
    wait click element    css=#_vpc
    wait click element    jquery=button:contains(Create VPC)
    wait input element    css=input[ng-model="$ctrl.vpcNameBox.value"]    vpc-temp01
    Wait Until Page Contains    Basic Information

Dashborad-To-SecurityGroup
    enter dashboard
    wait click element    css=#_securityGroup
    wait click element    jquery=button span:contains(Create Security Group)
    Wait Until Page Contains    Description

Dashborad-To-Network ACLs
    enter dashboard
    wait click element    css=#_firewall
    wait click element    jquery=button span:contains(Create Network ACL)
    Wait Until Page Contains    Description

Dashborad-To-Eips
    enter dashboard
    wait click element    css=#_eip
    wait click element    jquery=button span:contains(Buy EIP)
    Wait Until Page Contains    Billing Mode

Dashborad-To-ShareBandwidth
    enter dashboard
    wait click element    css=#_shareBandwidth
    wait click element    jquery=button span:contains(Buy Shared Bandwidth)
    Wait Until Page Contains    Billing Mode

Dashborad-To-NAT Gateways
    enter dashboard
    wait click element    css=#_nat
    wait click element    jquery=button span:contains(Buy NAT Gateway)
    Wait Until Page Contains    Billing Mode

Dashborad-To-Elastic Load Balance
    enter dashboard
    wait click element    css=#_elb
    wait click element    jquery=button span:contains(Buy Enhanced Load Balancer)
    Wait Until Page Contains    Network Type

Dashborad-To-Peering Connections
    enter dashboard
    wait click element    css=#_peering
    wait click element    jquery=button span:contains(Create VPC Peering Connection)
    Wait Until Page Contains    Local VPC Settings

Dashborad-To-VPC Endpoints
    enter dashboard
    wait click element    css=#_vpcep
    Wait Until Page Contains    Apply for VPC Endpoint OBT
    wait click element    jquery=button:contains(Apply Now)
    Select Window    new
    Wait Until Page Contains    Apply for Open Beta Test
    close new select old

Dashborad-To-VPN Gateways
    enter dashboard
    wait click element    css=#vpngwAll >span
    wait click element    jquery=span:contains(Buy VPN Gateway)
    Wait Until Page Contains    Billing Mode

Dashborad-To-Direct Connections
    enter dashboard
    wait click element    css=#dc_physicalDlines >span
    Wait Until Page Contains    To connect your network to HUAWEI CLOUD, you must first create a connection
    wait click element    css=a[ng-href="#/dc/createPhyDlinePartner"]
    Wait Until Page Contains    Your Equipment Room Address

Dashborad-To-Cloud Connection
    enter dashboard
    wait click element    css=#cloudConnect_cnsAll >span
    wait click element    css=#createCCBtn > span.cti-btn-label.ng-binding.ng-scope
    Wait Until Page Contains    Description

Dashborad-To-VPN Connections
    enter dashboard
    wait click element    css=#vpngwAll >span
    wait click element    jquery=span:contains(Buy VPN Gateway)
    Wait Until Page Contains    Billing Mode

测试用例Test_Vpcs.robot

*** Settings ***
Suite Setup       Login_retry
Suite Teardown    Close Browser
Library           Selenium2Library
Resource          common.txt

*** Test Cases ***
Create_vpc
    [Tags]    hec
    wait click element    css=#_vpc
    wait click element    jquery=button:contains(Create VPC)
    wait input element    css=input[ng-model="$ctrl.vpcNameBox.value"]    vpc-temp01
    Wait Until Page Contains    Basic Information

*** Keywords ***

文章来源: blog.csdn.net,作者:懿曲折扇情,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/qq_41332844/article/details/126837455

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。