selenium: How to solve the timeout problem caused by opening the web page for a long time to load

After selenium opens the webpage, even though the page has been loaded and can be operated, the address bar of the browser is still spinning, and the code behind it has been unable to execute. In fact, most of the reasons are due to the slow loading of static files or the failure of the CDN of the external link.

question

selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 300.000
insert image description here

Solution

After setting the timeout period, the page does not have to be fully loaded before the next step can be performed

browser = webdriver.Chrome(executable_path=self.path)
browser.set_page_load_timeout(1800)  # 根据页面实际需要加载时间设置

Reference document: https://blog.csdn.net/qq_33480558/article/details/126062337

Guess you like

Origin blog.csdn.net/xiaoyurainzi/article/details/130192407