ChromeDriver 77.0 (支持Chrome 77版本)现在支持 eager
作为 pageLoadStrategy 。
已解决的问题1902:支持优先页面加载策略[Pri-2]
如您所提,
click on elements and scrape data before the page has fullyloaded在这种情况下,我们可以利用属性
pageLoadStrategy。当Selenium默认加载页面/ URL时,它将遵循默认配置,
pageLoadStrategy设置为
normal。Selenium可以从不同的代码开始执行下一行代码
documentreadiness state。目前,Selenium支持3种不同的功能
document readiness state
,我们可以通过
pageLoadStrategy以下方式进行配置:
none
(未定义)eager
(页面变为交互式)normal
(完整的页面加载)
这是配置代码的代码块 pageLoadStrategy
:
from selenium import webdriverfrom selenium.webdriver.common.desired_capabilities import DesiredCapabilitiesbinary = r'C:Program FilesMozilla Firefoxfirefox.exe'caps = DesiredCapabilities().FIREFOX# caps["pageLoadStrategy"] = "normal" # completecaps["pageLoadStrategy"] = "eager" # interactive# caps["pageLoadStrategy"] = "none" # undefineddriver = webdriver.Firefox(capabilities=caps, firefox_binary=binary, executable_path="C:\Utility\BrowserDrivers\geckodriver.exe")driver.get("https://google.com")


