您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

通过Python3使用Selenium和WebDriver切换选项卡时,“ NoSuchWindowException:没有这样的窗口:窗口已经关闭”

通过Python3使用Selenium和WebDriver切换选项卡时,“ NoSuchWindowException:没有这样的窗口:窗口已经关闭”

感谢Debanjan(并为以后的回复表示歉意-刚回到办公室)。我能够通过使用解决此问题

While True:
    try:
        [navigate to the new frame, wait for a specific element to show up]
        break
    except (NoSuchWindowException, NoSuchElementException):
        pass

我没有意识到,当我单击打开表单时,另一个窗口在后台非常短暂地打开,然后关闭。这将window_handles增加到2,因此执行与等待2个窗口句柄有关的任何操作仍然会引发错误

python 2022/1/1 18:13:43 有802人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶