Keys.ESCAPE在硒webdriver(python) [英] Keys.ESCAPE in selenium webdriver(python)
问题描述
我正在使用selenium webdriver
(用 python
)。我有一个用例,我想测试提交按钮被禁用,一旦表单获取submited。为了测试它,我发送 ESCAPE
键停止页面加载下一页,以便我可以访问同一页面的元素。
password.send_keys(abcdef,Keys.ENTER,Keys.ESCAPE)
问题是,它在Firefox浏览器中正常工作,但在Chrome中不起作用。在Chrome中,发送 ESCAPE
似乎不起作用,它会提交表单并加载下一页。
任何其他的解决方案或解决方法来克服这一点?
在尝试了很多选项后,最后下面的选项似乎工作 - p>
password.send_keys(abcdef,Keys.ENTER,Keys.ESCAPE)#这适用于Firefox驱动
驱动。 ()#这个工程适用于Chrome驱动程序
I am using selenium webdriver
(with python
). I have a use case where I want to test that submit button get disabled once the form get submited. To test it, I send ESCAPE
key to stop the page to load next page so that I can access the elements of same page.
password.send_keys("abcdef", Keys.ENTER, Keys.ESCAPE)
The problem is that it works fine in Firefox browser but it is not working in Chrome. In Chrome sending ESCAPE
seems to be not working and it submits the form and loads the next page.
Is there any other solution or workaround to overcome this?
After trying many options, finally the following option seems to be working -
password.send_keys("abcdef", Keys.ENTER, Keys.ESCAPE) # this works for Firefox driver
drive.execute_script("window.stop();") # this works for Chrome driver
这篇关于Keys.ESCAPE在硒webdriver(python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!