自动化测试 RF+Jenkins+git

  •   RF 公共文件resource.txt
*** Settings ***
Library           SeleniumLibrary
Library    String

*** Variables ***
${host}           http://192.168.10.185:18090
${loginUrl}     /#/login
${username-admin}         alam
${password-admin}       666666
${pwdXpath}       //input[@type='password']
${usernameXpath}       //div[@id='app']/div/div/form/input
${captchaXpath}       //div[@id='app']/div/div/form/div[2]/input
${loginBtnXpath}       //button[@type='button']
${menu_auth}        //ul[@id='menu']/li[5]/div
${menu_setting}      //ul[@id='menu']/li[6]/div
#${table_path}           //*[@id="app"]/div/div[3]/div/div[2]/div/div[1]/div[2]/table
${table_path}            //*/text()[normalize-space(.)='序号']/parent::*

*** Keywords ***
login
    [Arguments]    ${username}    ${password}
    ${newUrl}=      Catenate    SEPARATOR=      ${host}    ${loginUrl}
    Open Browser    ${newUrl}    Chrome
    Set Browser Implicit Wait    10
    Maximize Browser Window
    Input Text    xpath=${usernameXpath}    ${username}
    Input Text    xpath=${pwdXpath}         ${password}
    Input Text    xpath=${captchaXpath}         ikas
    Click Element    xpath=${loginBtnXpath}
    Sleep    2

login-admin
    login       ${username-admin}       ${password-admin}


click
    [Arguments]    ${element}
    Sleep    1
    Click Element  ${element}

type
    [Arguments]    ${element}    ${value}
    Sleep    1
    Input Text     ${element}    ${value}

open
    [Arguments]    ${element}
    Sleep    1
    Go To          ${element}

Table1RowShouldContain
    [Arguments]    ${table_path}        ${name}
    Sleep    1
    Table Row Should Contain    xpath=${table_path}    1    ${name}

  

  • RF 登录
*** Settings ***
Resource          resource.txt
Test Teardown     close browser

*** Test Cases ***
login
    [Template]      login-Validation
    alam          666666      系统首页
    alam111       666666      用户不存在
    alam          888888      密码错误

*** Keywords ***
login-Validation
    [Arguments]    ${username}    ${password}       ${keywords}
    login       ${username}       ${password}
    Page Should Contain     ${keywords}
    close browser
  •    业务case
*** Settings ***
Resource          resource.txt
Test Setup        login-admin
Test Teardown     close browser


*** Variables ***
${menu_side_bar}           //div[@id='app']/div/div/div[2]/img
${menu_home}                 //div[@id='app']/div/div[2]/div/div/ul/li
${menu_scheduling}            //div[@id='app']/div/div[2]/div/div/ul/li[4]/div
${menu_schedulingInput}                   //div[@id='app']/div/div[2]/div/div/ul/li[4]/ul/li
${schedulingInput_url_path}           /scheduling/schedulingInput
@{rows}        计划编码  计划版本号  排程计划生成时间  配置参数数量  模型状态
*** Keywords ***


*** Test Cases ***
APS排程输入 - 进入
    # login-admin
    Page Should Contain     IKAS-智能生产排程系统
    click    xpath=${menu_side_bar}
    click    xpath=${menu_home}
    click    xpath=${menu_scheduling}
    click    xpath=${menu_schedulingInput}
    FOR    ${row_name}    IN    @{rows}
        Page Should Contain     ${row_name}
        # Table1RowShouldContain    ${table_path}    ${row_name}
    END
    Location Should Contain     ${schedulingInput_url_path}
    ${schedulingInput_url}    Log Location
    log     ${schedulingInput_url}
    Set Suite Variable    ${schedulingInput_url}

  然后放在git管理平台

Jenkins配置

 

  •  执行如图

 

  •  最后一个邮件

 

posted @ 2022-05-11 16:12  AlamZ  阅读(134)  评论(0编辑  收藏  举报