[英]TimeoutException: Message: Timed out waiting for page to load
I want to Open browser in Edge with IE mode.我想用 IE 模式在 Edge 中打开浏览器。 My environment: IE7, windows 11, Python 3.10.4, Edge version 108.0.1462.46 And I follow the required configuration from below: https://www.selenium.dev/documentation/ie_driver_server/
我的环境:IE7、Windows 11、Python 3.10.4、Edge 版本 108.0.1462.46 我按照下面的要求配置: https ://www.selenium.dev/documentation/ie_driver_server/
Is there any wrong steps about my configuration?我的配置有什么错误的步骤吗?
Below is my code:下面是我的代码:
*** Settings ***
Library SeleniumLibrary
*** Variables ***
${IEDriver} D:\\IEDriver\\64bits\\IEDriverServer.exe
*** Test Cases ***
Example Test
Open Browser https://www.google.com.tw/ ie executable_path=${IEDriver} options=ignore_zoom_level=True; attach_to_edge_chrome=True; edge_executable_path="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
Maximize Browser Window
After I executing my code, I can open google in Edge with IE mode, but after that web page stuck and always get thie error message: TimeoutException: Message: Timed out waiting for page to load.执行我的代码后,我可以使用 IE 模式在 Edge 中打开谷歌,但在该网页卡住之后,总是会收到错误消息:TimeoutException: Message: Timed out waiting for page to load。
This option may work for you in Windows 11 IE mode automation.此选项可能适用于 Windows 11 IE 模式自动化。 Check it out:
看看这个:
ignore_protected_mode_settings = True
UPDATE更新
Or you can simply try setting the page load timeout according to your requirement:或者您可以简单地尝试根据您的要求设置页面加载超时:
*** Variables ***
${orig timeout} 15 seconds
*** Test Cases ***
Example Test
Set Selenium Timeout ${orig timeout}
If the element you'd like to interact with has been fully loaded, you can skip the page loading and continue.如果您要与之交互的元素已完全加载,您可以跳过页面加载并继续。 A native Python example:
原生 Python 示例:
driver.set_page_load_timeout(10)
try:
driver.get('https://google.com')
except TimeoutException:
print
'!!!!!!time out after 10 seconds!!!!!!'
driver.execute_script("window.stop()")
In Robot Framework:在机器人框架中:
*** Test Cases ***
Example Test
Set Selenium Timeout ${orig timeout}
TRY
Open Browser https://www.google.com ie options=ignore_zoom_level=True; attach_to_edge_chrome=True; edge_executable_path="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
EXCEPT '!!!!!!time out after 10 seconds!!!!!!'
Execute Javascript window.stop()
END
Maximize Browser Window
And I found something interesting: I use python and selenium and below is my code:我发现了一些有趣的东西:我使用 python 和 selenium,下面是我的代码:
ieOptions = webdriver.IeOptions()
ieOptions.add_additional_option("ie.edgechromium", True)
ieOptions.add_additional_option("ie.edgepath",'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe')
driver = webdriver.Ie(options=ieOptions)
driver.maximize_window()
driver.get('https://google.com')
driver.quit()
If I remove this line "driver.get('https://google.com')" and my code runs perfectly.如果我删除这一行“driver.get('https://google.com')”并且我的代码运行完美。 But If I add it back, the page will go to goole and stuck there (It means that this code will not do driver.quit()
但是如果我把它加回去,页面就会变成 goole 并卡在那里(这意味着这段代码不会执行 driver.quit()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.