全局关键字 - 18570580798/study GitHub Wiki
*** Settings *** Library Collections Library OperatingSystem Library SeleniumLibrary Library Remote 10.233.48.65:8270 WITH NAME Crypt
*** Keywords *** WM Click Element [Arguments] ${locator} Wait Until Page Contains Element ${locator} Wait Until Element Is Visible ${locator} Click Element ${locator}
WM Click Link [Arguments] ${locator} Wait Until Page Contains Element ${locator} Wait Until Element Is Visible ${locator} Click Link ${locator}
WM Click Button [Arguments] ${locator} Wait Until Page Contains Element ${locator} Wait Until Element Is Visible ${locator} Click Button ${locator}
WM Click Button By Text [Arguments] ${text} ${locator} Set Variable jquery=button:contains(${text}) wait until page contains element ${locator} wait until element is visible ${locator} Click Button ${locator}
WM Decrypt [Arguments] ${string} ${ret} Decrypt ${string} [Return] ${ret}
WM Encrypt [Arguments] ${string} ${ret} Encrypt ${string} [Return] ${ret}
WM Get System Variable [Arguments] ${env_name} ${status} run keyword and return status Environment Variable Should Be Set ${env_name} ${value} run keyword if '${status}'=='${True}' Get Environment Variable ${env_name} [Return] ${value}
WM Get Table Cell By Colname [Arguments] ${tableLocator} ${rownum} ${colname} ${isEqual}=${False} ${header}=th @{cols} Get Webelements ${tableLocator}>thead>tr>${header} : FOR ${i} ${c} IN ENUMERATE @{cols} \ ${coltext} get text ${c} \ Continue For Loop If '${coltext.strip()}'=='${EMPTY}' \ ${statusContain} Run Keyword If '${isEqual}'!='${True}' Run Keyword And Return Status Should Contain ${coltext} \ ... ${colname} \ ${statusEqual} Run Keyword If '${isEqual}'=='${True}' Run Keyword And Return Status Should Be Equal ${coltext} \ ... ${colname} \ Exit For Loop if ${statusContain} or ${statusEqual} ${i} evaluate ${i}+1 ${rownum} Evaluate ${rownum}+1 ${tdata} Get Table Cell ${tableLocator} ${rownum} ${i} [Return] ${tdata}
WM Fill Form Content [Arguments] ${modal_locator} @{list} wait until page contains element ${modal_locator} Wait Until Element Is Visible ${modal_locator} @{input_list} Get Webelements ${modal_locator}//input[not(@type='hidden') and not(@readonly='readonly') and not(@disabled='disabled') and not(@type='button') and not(contains(@style,"display: none"))] @{select_list} Get Webelements ${modal_locator}//select[not(@type='hidden') and not(contains(@style,'display:none')) and not(contains(@disabled,'disabled'))] @{locator_list} Combine Lists ${input_list} ${select_list} : FOR ${item} ${locator} IN ZIP ${list} ${locator_list} \ @{item} Set Variable ${item.split('=')} \ Run Keyword If '${item[0]}'=='radio' or '${item[0]}'=='checkbox' WM Set Checkbox ${locator} ${item[1]} \ Run Keyword If '${item[0]}'=='text' and '${item[1]}'!='${EMPTY}' Input Text ${locator} ${item[1]} \ ... ELSE IF '${item[0]}'=='text' and '${item[1]}'=='${EMPTY}' Clear Element Text ${locator} \ Run Keyword If '${item[0]}'=='select' and '${item[1]}'!='${EMPTY}' WM Select By Label ${locator} ${item[1]}
WM Get Table Cells In Column By Colname [Arguments] ${tableLocator} ${colname} ${isEqual}=${False} ${header}=th ${rowCount} WM Get Table Row Count ${tableLocator} @{list} Create List : FOR ${i} IN RANGE ${rowCount} \ ${rownum} Evaluate ${i}+1 \ ${data} WM Get Table Cell By Colname ${tableLocator} ${rownum} ${colname} ${isEqual} \ ... ${header} \ Insert Into List ${list} ${i} ${data} [Return] @{list}
WM Get Table Row Count [Arguments] ${tableLocator} @{rows} Get Webelements ${tableLocator}>tbody>tr ${count} Get Length ${rows} [Return] ${count}
WM Get Text [Arguments] ${locator} Wait Until Page Contains Element ${locator} Wait Until Element Is Visible ${locator} ${text} Get Text ${locator} [Return] ${text}
WM Input Text [Arguments] ${locator} ${text} Wait Until Page Contains Element ${locator} Wait Until Element Is Visible ${locator} Input Text ${locator} ${text}
WM Input Text By Label Text [Arguments] ${text} ${value} @{label} Set Variable div td span @{path} Set Variable + +td> + ${status} Set Variable FALSE : FOR ${l} ${p} IN ZIP ${label} ${path} \ ${locatior} Set Variable jquery=${l}:contains(${text})${p}input \ ${status} WM Is Element Present ${locatior} \ comment log ${l}:${status} \ run keyword if ${status}==True run key words input text ${locatior} ${value} \ ... AND exit For loop Run Keyword If ${status}==False FAIL Can't find input element
WM Is Element Present [Arguments] ${locator} @{list} Get Webelements ${locator} ${len}= Get Length ${list} ${ret}= Set Variable If ${len}>0 ${True} ${False} [Return] ${ret}
WM Kill Webdriver ${os} evaluate platform.system() modules=platform run keyword if '${os}'=='linux' run pkill -9 chromedriver ... ELSE IF '${os}'=='Windows' Run taskkill /f /im chromedriver* >nul 2>nul
WM Open Browser [Arguments] ${url}=${None} [Documentation] 如环境变量中存在ROBOT_REMOTE_SERVER,则远程通过selenium remote server启动浏览器; ... 如参数${url}为空,则尝试获取${HOMEPAGE_URL},需要通过导入资源文件或设置robot全局变量来设置。 ${remote_url} WM Get System Variable ROBOT_REMOTE_SERVER ${homepage_url} Get Variable Value ${HOMEPAGE_URL} ${url} Set Variable If '${url}'=='${None}' ${homepage_url} ${url} run keyword if '${remote_url}'!='${NONE}' Open Browser ${url} gc remote_url=${remote_url} ... ELSE Open Browser ${url} gc
WM Select By Label [Arguments] ${locator} @{label} Wait Until Page Contains Element ${locator} Wait Until Element Is Visible ${locator} Select From List By Label ${locator} ${label}
WM Select Radio Button [Arguments] ${name} ${value} Wait Until Page Contains Element ${name} Wait Until Element Is Visible ${name} Select Radio Button ${name} ${value}
WM Set Checkbox [Arguments] ${locator} ${boolean} wait until page contains element ${locator} wait until element is visible ${locator} run keyword if ${boolean}==${True} Select Checkbox ${locator} ... ELSE Unselect Checkbox ${locator}
WM Set Input Text [Arguments] ${locator} ${text} Wait Until Page Contains Element ${locator} Wait Until Element Is Visible ${locator} Clear Element Text ${locator} input text ${locator} ${text}
WM Suite Teardown [Documentation] 环境变量中存在ROBOT_ENVIRONMENT=develop时,若套件报错时只杀掉webdriver进程,不关闭浏览器 ${env} WM Get System Variable ROBOT_ENVIRONMENT run keyword if '${env}'!='develop' or '${SUITE STATUS}'=='PASS' Close All Browsers ... ELSE IF '${env}'=='develop' and '${SUITE STATUS}'=='FAIL' WM Kill Webdriver