gpt4 book ai didi

python - Selenium 点击后无法继续?

转载 作者:太空宇宙 更新时间:2023-11-03 20:38:51 33 4
gpt4 key购买 nike

我正在使用 Internet Explorer 来自动化网站流程。该网站只能在 Internet Explorer 中运行,我无法使用任何其他浏览器。

使用的技术:Python3、Selenium、InternetExplorer

该代码非常适合 chromedriver。但是,对于 InternetExplorer,在第一页上执行单击后,没有任何效果,并且后续步骤开始崩溃。

我尝试按 F12 打开开发人员控制台来调试错误。令人惊讶的是,一切开始运行得很好,只是出现了一些小故障。

有人可以向我解释一下如何解决这个问题吗?我是否需要更改一些首选项,以便能够在没有开发者控制台的情况下访问该功能。

我收到以下错误:

NoSuchWindowException: Currently focused window has been closed

或者,我尝试使用 document.findElementByID().click() 通过 javascript 执行点击,适用于某些情况,但并非全部。

最佳答案

当您尝试与 Selenium 元素交互时,您会得到:

Exception in thread "main" org.openqa.selenium.NoSuchWindowException: Currently focused window has been closed.

确保您已更改保护模式(参见上文:https://github.com/seleniumQuery/seleniumQuery/wiki/seleniumQuery-and-IE-Driver#change-the-protected-mode-in-all-zones)。

另外,您是否执行了 Required Configuration 的所有步骤? ?

如果您有疑问,最后一点:

For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.

与执行包含此内容的 .reg 文件相同(上面的 Windows 64 位示例):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE]
"iexplore.exe"=dword:00000000

引用:

NoSuchWindowException: Currently focused window has been closed.

关于python - Selenium 点击后无法继续?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56983018/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com