简体   繁体   中英

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

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?

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()

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