Selenium Webdriver等待按钮文本更改 [英] Selenium Webdriver wait for button text to change
本文介绍了Selenium Webdriver等待按钮文本更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试自动化一个场景(在Ruby中),其中按钮的初始文本为激活",一旦单击该按钮,则需要3-5秒的时间进行必要的操作,然后按钮的文本变为取消激活".
I am trying to automate a scenario (in Ruby) where button initial text is 'Activate', once it is clicked, it takes 3-5 seconds to do what ever necessary then the button text changes to 'Deactivate'.
由于该按钮始终存在,因此使用以下代码无济于事.
Because the button always exist, using following code does not help.
wait.until {
driver.find_element(:id => 'changeStatus')
}
我如何要求网络驱动程序等待5秒钟,然后单击后检查按钮文本.
How can i ask webdriver to wait for 5 seconds before checking the button text after clicking.
推荐答案
您应该可以稍等一下,然后查找文本
You should be able to do a wait and look for the text instead
wait.until {
driver.find_elements_by_xpath("//*[text()='Deactivate']")
}
这篇关于Selenium Webdriver等待按钮文本更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文