Selenium-Python with chromium browser (windows)

南楼画角 提交于 2020-08-05 10:43:12

问题


I am trying to launch chromium browser with selenium python on windows 8.

Added binary_location as chromium binary location which is appdata. But still chromedriver starts google chrome instead of chromium.

If I uninstall google chrome, then chromedriver by default launches chromium. But with chrome installed it always launches chrome regardless.

Does anyone have an idea on how to start chromium with selenium while chrome installed?

Please do not mark it as duplicate. The other one was about unix and solution provided to selenium java while this one is about windows and python.


回答1:


Try this:

from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = r"D:\.....\chrome.exe"
# This line defines your Chromium exe file location.

driver = webdriver.Chrome(chrome_options=options)
driver.get('https://www.google.com/')

Worked for me. I installed both Chrome and Chromium. It starts the specified exe.




回答2:


To start Chromium browser you can use the following code block :

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

options = Options()
options.binary_location("C:\\path\\to\\chrome.exe") //path to chromium binary
options.add_argument("start-maximized")
options.add_argument("--disable-gpu-vsync") //only for Windows
options.add_argument("--remote-debugging-port=9222") //for MAC & Linux
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)
driver.get('http://google.com/')

Note : Here you can find more details about Run Chromium with flags



来源:https://stackoverflow.com/questions/49298245/selenium-python-with-chromium-browser-windows

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