How to initiate a Chromium based Vivaldi browser session using Selenium and Python

橙三吉。 提交于 2020-08-07 06:21:39

问题


I am trying to use the vivaldi browser with Selenium. It is a chromium browser that runs very similar to chrome. I have Selenium working with Firefox (geckodriver), and Google Chrome(chromedriver), but I can't seem to find a way with Vivaldi. Any help would be appreciated.


回答1:


If the vivaldi binary by default is located at C:\Users\levir\AppData\Local\Vivaldi\Application\vivaldi.exe you can use the following solution:

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

options = Options()
options.add_argument("start-maximized")
options.binary_location=r'C:\Users\levir\AppData\Local\Vivaldi\Application\vivaldi.exe'
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', options=options)
driver.get('http://google.com/')



回答2:


You can use ChromeOptions and supply binary.

from selenium.webdriver.chrome.options import Options


opt = Options()
opt.binary_location = chromium_path//path to chromium binary
driver = webdriver.Chrome(options=opt, executable_path="path_to_chromedriver")


来源:https://stackoverflow.com/questions/59644818/how-to-initiate-a-chromium-based-vivaldi-browser-session-using-selenium-and-pyth

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