【发布时间】:2016-10-26 10:21:23
【问题描述】:
我正在尝试使用 selenium 从某个页面导航到另一个页面:
driver = webdriver.Chrome()
driver.get("...some page...")
... # the alert does not exist yet and thus cannot be accepted
driver.get("...some other page...") # the alert pops up here and blocks navigation to 'some other page'
# execution never reaches here
...
现在,离开“某个页面”会触发警报,要求确认用户是否真的想离开该页面。这会永远阻止执行。设置了隐式超时,但不会由此触发。我无法让 selenium 接受警报,因为只在调用 'get' 后出现。
有没有办法解决这个问题?
非常感谢!
【问题讨论】:
-
为什么不能接受警报?显示代码你如何尝试接受它
-
我无法接受警报,因为它只在调用
get后出现。然后执行被卡住。所以我在调用get之前既不能接受警报,因为它还不存在,也不能在之后接受,因为执行永远不会超过get -
但是,您可以接受此警报。那么你如何尝试接受它呢?向我们展示您使用的代码示例
-
我会更改问题以使其更清楚
-
我在问题的代码中添加了一些 cmets。现在清楚了吗?
标签: python selenium selenium-chromedriver