无法使用 Chromedriver 和 Selenium 初始化远程 JxBrowser

Cant initialize remote JxBrowser using Chromedriver and Selenium

我正在尝试自动化 JavaFx 应用程序,该应用程序具有用于登录的集成网页。 我正在使用此处找到的代码:https://jxbrowser.support.teamdev.com/support/solutions/articles/9000013135-jxbrowser-selenium 一切都在我的本地机器上运行良好。 问题是我需要在远程机器上打开应用程序并与之集成。 上面的代码不起作用,我得到

unknown error: cannot connect to chrome at 192.168.2.147:9222
from chrome not reachable

错误。

我尝试了另一种不使用 chromeDriverService 而是使用 selenium 网格的方法,它看起来像这样:

DesiredCapabilities capabilities = new DesiredCapabilities();
ChromeOptions options = new ChromeOptions();

String remoteDebuggingAddress = add + ":9222";

options.setExperimentalOption("debuggerAddress", remoteDebuggingAddress);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);

LoggingPreferences logs = new LoggingPreferences();
logs.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);

jxDriver = new RemoteWebDriver(new URL("http://" + add + ":5555" + "/wd/hub"), capabilities);
return jxDriver;

我运行 5555端口上的集线器和machine机器上的节点。 chromeDriver 在路径 envVar 中,我在 cmd window 中看到发送了一个连接请求。 结果是一样的。

任何人都可以告诉我我在这里做错了什么吗? 这种远程 jxbroswer 自动化是否可行?

编辑: 当我在远程机器上初始化一个 Chrome 会话时,它按预期工作(使用硒网格)但是当我添加

options.setExperimentalOption("debuggerAddress", remoteDebuggingAddress);

失败并出现同样的错误。

这个错误信息...

unknown error: cannot connect to chrome at 192.168.2.147:9222 from chrome not reachable

...意味着 ChromeDriver 无法 initiate/spawn 新的 Browsing ContextChrome 浏览器 会话。

您的主要问题是您使用的二进制文件版本之间不兼容

至于 driven controlled is concerned you are following the correct documentation

然而,在这个 @SerhiiFedchenko mentioned, this particular approach was tested with Selenium WebDriver 2.46 and ChromeDriver 2.16. JxBrowser was not tested with the older/newer versions of Selenium WebDriver and .


解决方案

一个可能的解决方案是使用二进制文件的测试版本执行测试:

  • 硒网络驱动程序 2.46
  • Chrome驱动程序 2.16

所以我能够找到解决方案,问题是我发送到“debuggerAddress”的 IP。 当我发送远程机器 IP 时,我应该使用“localhost”,因为已经使用 selenium 网格建立了连接。