gpt4 book ai didi

java - 使用命令行参数使用Selenium WebDriver启动Electron应用程序

转载 作者:行者123 更新时间:2023-12-03 12:23:26 28 4
gpt4 key购买 nike

我有一个Electron应用程序(chat.exe),使用以下代码片段可以用Chromedriver启动它:

ChromeOptions options = new ChromeOptions();
options.setBinary(System.getenv("CHAT")); // CHAT = path to Chat.exe
driver = new ChromeDriver(options);

我的问题是:如何使用命令行参数启动它?

例如 chat.exe -- --electronPort 5000 --webpackPort 3000 --accessToken 123456789
我尝试了以下方式,但没有成功:

ChromeOptions options = new ChromeOptions();
options.setBinary(System.getenv("CHAT")); // CHAT = path to Chat.exe
options.addArguments("-- --electronPort 5000 --webpackPort 3000 --accessToken 123456789");
driver = new ChromeDriver(options);

显示以下错误:
org.openqa.selenium.WebDriverException: chrome not reachable

最佳答案

以下格式有效(按@ user861594指定):

options.addArguments("<Key>=<value>");

但是,问题是chromedriver无法接受camelCase格式的参数。在开发人员将cli args的语法从camelCase修改为连字符后,上述解决方案起作用了。

例如
options.addArguments("electron-port=5000");
options.addArguments("webpack-port=3000");
options.addArguments("access-token=12345‌​6789");

关于java - 使用命令行参数使用Selenium WebDriver启动Electron应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37109041/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com