【问题标题】:How to verify value of first google search result using Robot Framework?如何使用机器人框架验证第一个谷歌搜索结果的价值?
【发布时间】:2022-06-22 23:40:47
【问题描述】:

如何在 Robot Framework 中执行以下操作:断言谷歌搜索“stackoverflow.com”的第一个结果是 stackoverflow.com 网站?目前正在学习 Robot 框架,使用 Python 和 Selenium2Library。

【问题讨论】:

    标签: python robotframework selenium2library


    【解决方案1】:

    你可以使用Should Be Equal As Strings关键字:

      Open Browser   https://www.google.com/  chrome
      Maximize Browser Window
      Wait Until Element Is Visible    xpath=//input[contains(@class,'gLFyf')]
      Input Text    xpath=//input[contains(@class,'gLFyf')]    stackoverflow.com
      Press Keys    xpath=//input[contains(@class,'gLFyf')]    ENTER  
      ${first_result}=    Get Text    xpath=(//*[contains(@class,'LC20lb ')])[1]
      Should Be Equal As Strings    ${first_result}     Stack Overflow - Where 
      Developers Learn, Share, & Build ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-06
      • 2019-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-10
      相关资源
      最近更新 更多