简体   繁体   中英

How to open Chromium Browser through Selenium ChromeDriver and Python in Linux

I have a question. I use a chromedriver of course, when I start my test, pycharm open Chromium, I would like to open Chrome, how I can change this ? Maybe I can set this in my code?

def setUp(self)
        self.driver = webdriver.Chrome(chrome_options=chrome_options)
        self.driver.get("site")

Chromium Browser have different version as follows:

  • Chrome Canary
  • Chrome from Dev Channel
  • Raw build of Chromium for Windows x64

Not sure which Chromium Browser version you are trying to use.

However to use Chrome Canary version you can use the ChromeOptions and binary_location property through an instance of Options() class to set the absolute path of the Chrome Canary binary and you can use the following solution:

  • Code Block:

     from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument("start-maximized") options.binary_location="C:\\\\Users\\\\AtechM_03\\\\AppData\\\\Local\\\\Google\\\\Chrome SxS\\\\Application\\\\chrome.exe" driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\\Utility\\BrowserDrivers\\chromedriver.exe') driver.get('http://google.com/') 
  • Browser Snapshot:

Chrome_Canary


trivia

You need to download the latest Chromium binary from either of the official repositories:

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