问题描述
当我用selenium webdriver打开一个页面时,我得到一个对话框选择证书。默认证书是正确的,所以我只需点击确定按钮。但我有这个问题。我有python代码:
drv = webdriver.Chrome()
drv.get(https:// example .com / login)
之后,我想要做一些事情:
drv.switch_to_alert()。accept()
或
drv.switch_to_alert()。send_keys(Keys.TAB)
drv。 switch_to_alert()。send_keys(Keys.SPACE)
问题是代码在drv线路上停止执行.get()。 Webdriver正在等待页面加载。
如何处理这个问题?
你为什么要问?这是一个操作系统对话框,Selenium不会也可能永远不会处理,因此您必须转向其他解决方案(在C#中,您应该使用本机Win32 API方法来点击按钮)。
When I open a page with selenium webdriver I get a chrome dialog box "Choose certificate". The default certificate is the right one so I only have to click OK button. But I have problem with this. I have python code:
drv = webdriver.Chrome()
drv.get("https://example.com/login")
and after that I want to do something like:
drv.switch_to_alert().accept()
or
drv.switch_to_alert().send_keys(Keys.TAB)
drv.switch_to_alert().send_keys(Keys.SPACE)
The problem is that the code stops executing on line drv.get("https://example.com/login"). Webdriver is waiting for page to load. And before that line there is no chrome dialog box.
How can I handle this?
You'll have to use something like AutoIT:
http://www.autoitscript.com/site/autoit/
Why you ask? It's an OS dialog, which Selenium does not and probably never will handle, so you'll have to turn to other solutions (in C# you should use native Win32 API methods to click the button for instance).
这篇关于使用selenium webdriver chrome处理'选择数字证书'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!