Selenium: Options().add_argument, Options().add_experimental_option

761 Views Asked by At

I'm learning Selenium and trying to understand the parameters of the methods Chromdriver's Options class like add_argument, add_experimental_option, and so on. Where can I find information about these parameters?

I have referred to some documentation, but it seems that it's not enough, as there are some parameters that I couldn't find in the documentation. Can someone please explain this to me? I have tried to research it, but I still don't understand it clearly.

screenshot of usage

1

There are 1 best solutions below

2
gavin On

There are command-line switches that Chromium (and Chrome) accept in order to enable particular features or modify otherwise default functionality.

google-chrome --remote-debugging-port=9222

You can read more about running Chrome with command line params here.

Selenium provides the APIs to enable fine-grain control of your browser - in this case, Chrome. You can refer to the following documentation to get a high-level idea of the available methods & attributes for the Options interface.

options = Options()
options.add_experimental_option('excludeSwitches', ['enable-automation'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-setuid-sandbox")
options.add_argument('--disable-infobars')

You can read more about the different available APIs under the Options interface here.

To understand what options are available (which may vary depending on the version of your browser), you can refer to Chrome's official API documentation. Additionally, there are other resources online that try to compile this information in a common place: