Control Vivaldi browser

524 views Asked by At

I want to manage the tabs of Vivaldi (Windows) using Python: get URLs, focus a specific tab, open, close, reload...
This post asks how to open Vivaldi, and my script does it, but not when/how it's supposed to do it:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import os

current_user = os.getlogin()
s = Service(rf"C:\Users\{current_user}\AppData\Local\Vivaldi\Application\vivaldi.exe")
driver = webdriver.Chrome(service=s)

The last line opens a new (unwanted) window of Vivaldi, which baffles me because I thought it should only declare a variable, and then nothing happens for some minutes. Finally I get this error:

Traceback (most recent call last):
  File "C:\Users\Negozio\Dropbox\D.Apps\Negozio\Conta\test.py", line 7, in <module>
    driver = webdriver.Chrome(service=s)
  File "C:\Program Files\Python310\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "C:\Program Files\Python310\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 90, in __init__
    self.service.start()
  File "C:\Program Files\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 105, in start
    raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service C:\Users\Negozio\AppData\Local\Vivaldi\Application\vivaldi.exe

I thought that Vivaldi should open with driver.get("http://url.com"), am I wrong? What's happening here, and above all how can I manage Vivaldi with Python?

0

There are 0 answers