Add color to Selenium Webdriver window

Viewed 180

I would like give a color to the Selenium WebDriver window's frame. (Attaching Image)enter image description here

I tired to do it with chrome_options = Options() and chrome_options.add_argument("default-background-color FFFFFF00")

That's my code:

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import ElementClickInterceptedException
from selenium.common.exceptions import ElementNotInteractableException
from selenium.common.exceptions import StaleElementReferenceException
import requests
import time

# Chrome driver
s = Service('C:\Program Files (x86)\chromedriver.exe')
chrome_options = Options()
chrome_options.add_argument("default-background-color FFFFFF00")
driver = webdriver.Chrome(service=s, options=chrome_options)
driver.maximize_window()
driver.get("https://www.google.com/")

It's not working for me. When happens is that the browser is opening with 2 tabs. The URL of the first one is the "80808000" and the second one is Google.com

enter image description here

There is any solution for it?

Thanks!

2 Answers

Looks like FFFFFF00 is the default background color.
Please try setting it to any other value like 80808000and see if it makes changes.

chrome_options = Options()
chrome_options.add_argument("default-background-color 80808000")
driver = webdriver.Chrome(service=s, options=chrome_options)

Then you will be able to set the color you want.

I guess that there is an issue with the syntax. I am not sure, but you can try:

chrome_options.add_argument("--default-background-color ff0000ff")
chrome_options.add_argument("--default-background-color=ff0000ff")
chrome_options.add_argument("--default-background-color:ff0000ff")

The argument "--default-background-color" is present in this list:
https://peter.sh/experiments/chromium-command-line-switches/ (referred from https://chromedriver.chromium.org/capabilities) https://source.chromium.org/chromium/chromium/src/+/main:headless/app/headless_shell.cc;l=363?q=default-background-color&sq=&ss=chromium

Related