seleniumn 启动时打开F12开发者工具

----------------------------------------------------------------------------------------------------------------------------------------
chromeOptions 是一个配置 chrome 启动是属性的类。通过这个类,我们可以为chrome配置如下参数(这个部分可以通过selenium源码看到):
  • 设置 chrome 二进制文件位置 (binary_location)
  • 添加启动参数 (add_argument)
  • 添加扩展应用 (add_extension, add_encoded_extension)
  • 添加实验性质的设置参数 (add_experimental_option)
  • 设置调试器地址 (debugger_address)

如上,看很多人提到chromeOptions和binary_location,但是chromedriver的执行路径怎么设置也不成功,提示如下错误:
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.
后来直接把路径写进去,就正常了,不知道什么原因。


新版建议使用Options替代chromeOptions
----------------------------------------------------------------------------------------------------------------------------------------
解决方案:
options = webdriver.chrome.options.Options(); options.add_argument("--auto-open-devtools-for-tabs"); driver = webdriver.Chrome(executable_path = 'C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe',options=options);
----------------------------------------------------------------------------------------------------------------------------------------
原文地址:https://www.cnblogs.com/BeyondTechnology/p/13944293.html