gpt4 book ai didi

selenium - 机器人框架 : How to make Wait until keyword from selenium library return true or false

转载 作者:行者123 更新时间:2023-12-05 01:11:56 24 4
gpt4 key购买 nike

如果页面上存在元素,我想运行关键字。

我尝试使用 Selenium 库的“等待页面包含元素”关键字,但无论该元素是否存在,它都会始终返回“无”。我尝试设置自定义错误,但这也不起作用:

${condition} =     Wait Until Page Contains Element    ${locator}    timeout=5   error=false
Run Keyword if '${condition}'=='false' click element ${some_refreshButton_locator}

关键字点击元素 ${locator} 仅在我设置条件 '${condition}'=='None' 时才会运行

我做错了什么,我怎样才能让 Selenium 库等到...关键字返回 true 或 false。

谢谢!

最佳答案

等到页面包含元素不返回任何内容,但如果未找到元素,则会引发错误。一种解决方法是将 Run Keyword And Ignore Error 包裹起来。

*** Settings ***
Library Selenium2Library

*** Test Cases ***
Test wait
Open Browser http://www.google.com/ gc
${result} ${condition}= Run Keyword And Ignore Error Wait Until Page Contains Stackoverflow timeout=2 error=false
Run Keyword if '${condition}'=='false' Log clicking
Close All Browsers

关于selenium - 机器人框架 : How to make Wait until keyword from selenium library return true or false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38899106/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com