【发布时间】:2021-11-09 19:39:33
【问题描述】:
我正在尝试设置一个测试环境,以通过 selenium 测试电子应用的 appimage。它基本上可以工作,但我的论点有问题。如果没有 selenium,对 appimage 的通常调用是 app.AppImage --profile test 。但是,当使用以下脚本时,调用的是app.AppImage --enable-logging --remote-debugging-port=0 --user-data-dir=/tmp/some/path:
from selenium import webdriver
chromedriver_service = webdriver.chrome.service.Service("./chromedriver")
chromedriver_service.start()
driver = webdriver.remote.webdriver.WebDriver(
command_executor=chromedriver_service.service_url,
desired_capabilities={
"goog:chromeOptions": {
"binary": "app.AppImage",
"excludeSwitches": [
"disable-background-networking",
"disable-client-side-phishing-detection",
"disable-default-apps",
"disable-hang-monitor",
"disable-popup-blocking",
"disable-prompt-on-repost",
"disable-sync",
"enable-automation",
"enable-blink-features",
"log-level",
"no-first-run",
"no-service-autorun",
"password-store",
"test-type",
"use-mock-keychain",
],
},
},
)
如何修改参数?
- 更重要:如何添加
--profile test?显而易见的方法是将"args": ["--profile", "test"]添加到chromeoptions。这不起作用。每个列表元素都将作为单独的参数处理。 - 不太重要:如何删除其他标志(主要是
--user-data-dir=)?这似乎无法直接实现(参见here)。
更多信息:webdriver 版本为 85.0.4183.87。
【问题讨论】:
标签: python selenium selenium-webdriver electron selenium-chromedriver