如何使用机器人框架获取所有链接并一一单击链接

时间:2019-05-27 06:43:34

标签: robotframework selenium2library

我正在使用机器人的做工

我正在从网页中获取所有链接,并试图一次单击每个链接。检查响应200或404或500

*设置*

图书馆Selenium2Library

图书馆馆藏

*测试用例*

获取所有链接

[Tags]    Links
Open Browser    URL    gc
Input Username  ${EMAIL}
input password  ${PASSWORD}
Submit Credentials
Maximize Browser Window
Comment    Count Number Of Linkds on the Page
${AllLinksCount}=    Get Matching Xpath Count    //a
Comment    Log links count
Log    ${AllLinksCount}
Comment    Create a list to store link texts
@{LinkItems}    Create List
Comment    Loop through all links and store links value that has length more than 1 character
: FOR    ${INDEX}    IN RANGE    1    ${AllLinksCount}
\    Log    ${INDEX}
\    ${lintext}=    Get Text    xpath=(//a)[${INDEX}]
\    Log    ${lintext}
\    ${linklength}    Get Length    ${lintext}
\    Run Keyword If    ${linklength}>1    Append To List    ${LinkItems}    ${lintext}
${LinkSize}=    Get Length    ${LinkItems}
Log    ${LinkSize}
Comment    Print all links
: FOR    ${ELEMENT}    IN    @{LinkItems}
\    Log    ${ELEMENT}
Close Browser

0 个答案:

没有答案