[英]How to add arguments to the Splinter Browser() command?
我想自動化以下 Linux shell 命令:
google-chrome-stable --password-store=basic --user-data-dir=/tmp/chrome
使用splinter
(或selenium
),但我找不到解釋如何將參數和值傳遞給Browser
命令的文檔/示例。
以下(錯誤)代碼顯示了我的嘗試:
"""
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)
你能幫助正確的語法嗎?
這是它的完成方式:
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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.