简体   繁体   中英

Python Selenium, how do I open a page in dark mode?

im trying to open this page in dark mode, using selenium and python. however anything i try doesnt seem to work. this is the code i believe should work:

options = webdriver.ChromeOptions()
options.headless = False
options.add_argument('--force-dark-mode')
driver = webdriver.Chrome(options=options)

link = "https://www.reddit.com"

driver.get(link) 

a similar question was asked here but doesnt work.

also i have looked at the command switches , and it doesnt work for me.

I do see it is working, the driver browser is opened in the dark mode.
This is my code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--force-dark-mode')

s = Service('C:\webdrivers\chromedriver.exe')

driver = webdriver.Chrome(options=options, service=s)

url = 'https://www.reddit.com'

driver.get(url)

And this is the screenshot of the opened browser在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM