基础关键字 - 18570580798/study GitHub Wiki

1.按列名获取表格的单元格文本: WM Get Table Cell By Colname [Arguments] ${tableLocator} ${rownum} ${colname} ${isEqual}=${False} @{cols} Get Webelements ${tableLocator}>thead>tr>th : 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}

2.处理单选框、复选框的 BSC_SetCheckbox [Arguments] ${locator} ${boolean} wait until page contains element ${locator} wait until element is visible ${locator} ${is_Checkbox_Selected}= Run Keyword And Return Status Checkbox Should Be Selected ${locator} run keyword if '${is_Checkbox_Selected}'!='${boolean}' Click Element ${locator}

BSC_SelectRadioButton [Arguments] ${name} ${value} Wait Until Page Contains Element ${name} Wait Until Element Is Visible ${name} Select Radio Button ${name} ${value}

  1. 文本框输入 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} Run Keyword And Return Status Wait Until Page Contains Element ${locatior} 0.5 \ 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

4.BSC_GetRowCount [Arguments] ${tableLocator} @{rows} Get Webelements ${tableLocator}>tbody>tr ${count} Get Length ${rows} [Return] ${count}

5.取表格的一整列文本 BSC_GetColumnCells [Arguments] ${tableLocator} ${colname} ${isEqual}=${False} ${rowCount} BSC_GetRowCount ${tableLocator} @{list} Create List : FOR ${i} IN RANGE ${rowCount} \ ${rownum} Evaluate ${i}+1 \ ${data} BSC_GetCellbyColnameUpdated ${tableLocator} ${rownum} ${colname} ${isEqual} \ Insert Into List ${list} ${i} ${data} [Return] @{list}

WM Kill Webdriver Run taskkill /f /im chromedriver* >nul 2>nul

WM Open Browser ${env_name} set variable ROBOT_REMOTE_SERVER ${status} run keyword and return status Environment Variable Should Be Set ${env_name} ${remote_url} run keyword if '${status}'=='${True}' Get Environment Variable ${env_name} run keyword if '${remote_url}'!='${NONE}' open browser ${HOMEPAGE_URL} gc remote_url=${remote_url} ... ELSE open browser ${HOMEPAGE_URL} gc

WM Suite Teardown run keyword if '${ENVIRONMENT}'!='dev' or '${SUITE STATUS}'=='PASS' Close All Browsers ... ELSE IF '${ENVIRONMENT}'=='dev' and '${SUITE STATUS}'=='FAIL' WM Kill Webdriver