Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Chrome Options in SeleniumBase #2346

Answered by mdmintz
joako233 asked this question in Q&A
Discussion options

Hello, good day. I don't know how to add this type of options for Chrome, but using SeleniumBase. Thanks in advance for the help.
Example:
options.add_argument(f"user-agent={user_agent}")
options.add_argument('--start-maximized')
options.add_argument('disable-web-security')
options.add_argument('disable-extensions')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--disable-blink-features=AutomationControlled')

You must be logged in to vote

The answer depends on which of the 23 SeleniumBase Syntax Formats you use.

If you're running tests with pytest, there are several command-line options available: (See pytest Options).
Eg. You can set the agent with --agent=AGENT. Start maximized with --maximize. Add any option you want with a comma-separated list: --chromium-arg="ARG1,ARG2=SOMETHING".
Find example tests in SeleniumBase/examples. (The pytest ones start with test_ or end in _test.py.)

You can also override browser_launcher.py with Syntax Format 9 or 10 and use options.add_argument() directly, but you will lose all the special SeleniumBase modes such as UC Mode (the most popular one). Example: test_override_driver.py.

If you...

Replies: 1 comment

Comment options

The answer depends on which of the 23 SeleniumBase Syntax Formats you use.

If you're running tests with pytest, there are several command-line options available: (See pytest Options).
Eg. You can set the agent with --agent=AGENT. Start maximized with --maximize. Add any option you want with a comma-separated list: --chromium-arg="ARG1,ARG2=SOMETHING".
Find example tests in SeleniumBase/examples. (The pytest ones start with test_ or end in _test.py.)

You can also override browser_launcher.py with Syntax Format 9 or 10 and use options.add_argument() directly, but you will lose all the special SeleniumBase modes such as UC Mode (the most popular one). Example: test_override_driver.py.

If you're using the Driver() manager format, there are several method args available, such as agent="AGENT", maximize=True, chromium_arg="ARG1,ARG2=SOMETHING", etc. Example: raw_driver_manager.py.

Note that many of your options are already set by default. (Find them in seleniumbase/core/browser_launcher.py) If you try to set something twice that was already set, you may encounter issues. (This could be possible if you are setting options with chromium_arg instead of via standard SeleniumBase options or method args.)

You must be logged in to vote
0 replies
Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /