How to add arguments to the Splinter Browser() command?

153 views Asked by At

I'd like to automate the following Linux shell command:

google-chrome-stable --password-store=basic --user-data-dir=/tmp/chrome

using splinter (or selenium), but I cannot find documentation/examples that explain how to pass arguments and values to the Browser command.

The following (wrong) code shows what I tried:

"""
google-chrome-stable --password-store=basic --user-data-dir=/tmp/chrome
"""

from splinter import Browser
from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("password-store", "basic")
chrome_options.add_experimental_option("user-data-dir", "/tmp/chrome")
browser = Browser('chrome', options=chrome_options)

Can you help with the correct syntax?

1

There are 1 answers

0
boardrider On

This is how it's done:

from splinter import Browser
import selenium.common.exceptions
from selenium import webdriver

def prepare_special_chrome():
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("--password-store=basic")
    chrome_options.add_argument("--user-data-dir=/tmp/chrome")
    browser = Browser('chrome', options=chrome_options)
    browser.visit('https://machine.local/#/')


if __name__ == "__main__":
    prepare_special_chrome()