What are 'service_args' for the selenium-python chrome webdriver?

ε祈祈猫儿з 提交于 2020-01-24 10:15:29

问题


I searched documentation for the argument service_args for the chrome webdriver, and I found the following pages: here and here, which unfortunately do not contain any useful content to answer my question.

So where can I find proper documentation on the service_args argument?


回答1:


The reason why this is not documented is unknown.

But most likely this option can be used to pass arguments to the chromedriver. The list of options can be seen by running

chromedriver --help

For version 2.24 of chromdriver you get the following list:

Usage: chromedriver [OPTIONS]

Options
  --port=PORT                     port to listen on
  --adb-port=PORT                 adb server port
  --log-path=FILE                 write server log to file instead of stderr, increases log level to INFO
  --verbose                       log verbosely
  --version                       print the version number and exit
  --silent                        log nothing
  --url-base                      base URL path prefix for commands, e.g. wd/url
  --port-server                   address of server to contact for reserving a port
  --whitelisted-ips               comma-separated whitelist of remote IPv4 addresses which are allowed to connect to ChromeDriver



回答2:


service_args are used inconjunction with chromedriver binary to pass the List of args to the chromedriver service

An example would be to pass the parameters e.g. log file path, to ignore ssl errors, any ssl protocol as follows :

service_args=["--log-path=D:\\Alex.log", "--ignore-ssl-errors=true", "--ssl-protocol=any"]

Your line of code will be :

driver = webdriver.Chrome(executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe', service_args=["--log-path=D:\\qc1.log", "--ignore-ssl-errors=true", "--ssl-protocol=any"])


来源:https://stackoverflow.com/questions/47283378/what-are-service-args-for-the-selenium-python-chrome-webdriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!