- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
设置 Selenium 网格:
我能够在命令提示符中使用以下命令设置网格(集线器和节点),然后能够启动浏览器并成功执行测试。
java -jar selenium-server-standalone-3.4.0.jar -role hub
java -jar selenium-server-standalone-3.4.0.jar -role webdriver -hub "http://localhost:4444/grid/register" -port 5566
当尝试通过脚本设置 Selenium 网格时,我能够成功设置集线器和节点,但无法启动浏览器。
请帮助解决问题。
请找到下面的代码和控制台:
package config.HubNode;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.internal.utils.SelfRegisteringRemote;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.internal.utils.configuration.GridNodeConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class HubNodeConfig {
public static void main(String[] args) throws Exception {
HubNodeConfig objHubNodeConfig = new HubNodeConfig();
objHubNodeConfig.HubConfig();
System.out.println("Hub Configured Successfully");
objHubNodeConfig.NodeConfig();
System.out.println("Node Configured to Hub Successfully");
objHubNodeConfig.InvokeBrowser();
}
public void HubConfig() throws Exception
{
GridHubConfiguration gridHubConfig = new GridHubConfiguration();
gridHubConfig.role = "hub";
gridHubConfig.host = "localhost";
gridHubConfig.port = 4444;
Hub myHub = new Hub(gridHubConfig);
myHub.start();
}
public void NodeConfig()
{
GridNodeConfiguration gridNodeConfig = new GridNodeConfiguration();
gridNodeConfig.hub = "http://localhost:4444/grid/register"
gridNodeConfig.host = "192.xxx.xx.xx" //my ip address
gridNodeConfig.port = 5566;
gridNodeConfig.role = "webdriver";
RegistrationRequest req = new RegistrationRequest(gridNodeConfig);
req.getConfiguration();
req.validate();
RegistrationRequest.build(gridNodeConfig);
SelfRegisteringRemote remote = new SelfRegisteringRemote(req);
remote.startRegistrationProcess();
}
public void InvokeBrowser() throws MalformedURLException
{
System.setProperty("webdriver.chrome.driver", "E:\\chromedriver.exe");
DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setBrowserName("chrome");
capability.setPlatform(Platform.WIN10);
WebDriver driver = new RemoteWebDriver(new URL("http://"+gridNodeConfig.host+":"+gridNodeConfig.port+"/wd/hub"), capability);
System.out.println("Driver Launched Successfully");
driver.get("https://google.com");
}
}
控制台错误消息和网格屏幕截图:
2017-07-20 23:57:17.135:INFO::main: Logging initialized @2576ms to org.seleniumhq.jetty9.util.log.StdErrLog
Jul 20, 2017 11:57:17 PM org.openqa.grid.web.Hub initServer
INFO: Will listen on 4444
2017-07-20 23:57:17.509:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-07-20 23:57:17.569:INFO:osjs.session:main: DefaultSessionIdManager workerName=node0
2017-07-20 23:57:17.570:INFO:osjs.session:main: No SessionScavenger set, using defaults
2017-07-20 23:57:17.573:INFO:osjs.session:main: Scavenging every 600000ms
2017-07-20 23:57:17.592:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@1a1d6a08{/,null,AVAILABLE}
2017-07-20 23:57:17.804:INFO:osjs.AbstractConnector:main: Started ServerConnector@77f99a05{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-07-20 23:57:17.804:INFO:osjs.Server:main: Started @3245ms
Hub Configured Successfully
Jul 20, 2017 11:57:19 PM org.openqa.grid.internal.utils.SelfRegisteringRemote$1 run
INFO: Starting auto registration thread. Will try to register every 5000 ms.
Jul 20, 2017 11:57:19 PM org.openqa.grid.internal.utils.SelfRegisteringRemote registerToHub
INFO: Registering the node to the hub: http: //localhost:4444/grid/register
Node Configured to Hub Successfully
Jul 20, 2017 11:57:19 PM org.openqa.grid.internal.Registry add
INFO: Registered a node http: //192.xxx.xx.xx:5566
Jul 20, 2017 11:57:19 PM org.openqa.grid.internal.utils.SelfRegisteringRemote registerToHub
INFO: The node is registered to the hub and ready to use
Exception in thread "main"
<b>org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.</b>
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'KRISH', ip: '192.xxx.xx.xx', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:658)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:174)
at config.HubNode.HubNodeConfig.InvokeBrowser(HubNodeConfig.java:71)
at config.HubNode.HubNodeConfig.main(HubNodeConfig.java:29)
<b> Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 192.xxx.xx.xx:5566 [/192.xxx.xx.xx] failed: Connection refused: connect </b>
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:139)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:87)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:343)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
... 6 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 21 more
>Jul 21, 2017 12:15:30 AM org.openqa.grid.selenium.proxy.DefaultRemoteProxy onEvent
INFO: Marking the node http: //192.xx.xx.xx:5566 as down: cannot reach the node for 2 tries
Jul 21, 2017 12:16:30 AM org.openqa.grid.selenium.proxy.DefaultRemoteProxy onEvent
INFO: Unregistering the node http: //192.xx.xx.xx:5566 because it's been down for 60077 milliseconds
Jul 21, 2017 12:16:30 AM org.openqa.grid.internal.Registry removeIfPresent
WARNING: Cleaning up stale test sessions on the unregistered node http: //192.xx.xx.xx:5566
Jul 21, 2017 12:16:34 AM org.openqa.grid.internal.utils.SelfRegisteringRemote registerToHub
INFO: Registering the node to the hub: http: //localhost:4444/grid/register
Jul 21, 2017 12:16:34 AM org.openqa.grid.internal.Registry add
INFO: Registered a node http: //192.xx.xx.xx:5566
Jul 21, 2017 12:16:34 AM org.openqa.grid.internal.utils.SelfRegisteringRemote registerToHub
INFO: The node is registered to the hub and ready to use
Jul 21, 2017 12:16:46 AM org.openqa.grid.selenium.proxy.DefaultRemoteProxy onEvent
INFO: Marking the node http: //192.xx.xx.xx:5566 as down: cannot reach the node for 2 tries
最佳答案
您启动节点的代码有问题。请按如下方式修复。
方法 nodeConfig()
不会将服务器注入(inject)到 SelfRegisteringRemote
中。
它应该是这样的:
RegistrationRequest req = RegistrationRequest.build(gridNodeConfig);
SelfRegisteringRemote remote = new SelfRegisteringRemote(req);
remote.setRemoteServer(new SeleniumServer(gridNodeConfig));
remote.startRemoteServer();
remote.startRegistrationProcess();
另外,请将您的 RemoteWebDriver
实例化代码更改为如下
WebDriver driver = new RemoteWebDriver(new URL("http://" + gridHubConfig.host + ":" + gridHubConfig.port + "/wd/hub"), capability);
注意,我们正在连接到 gridHubConfig
主机及其端口,而不是节点的端口(这正是您的代码所做的)。
一旦解决了这些问题,您的代码应该可以正常工作,并且您应该看到通过您的代码衍生出嵌入式网格。
关于selenium - 使用脚本设置 Selenium 网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45227403/
这个问题已经有答案了: Is there any way to accept only numeric values in a JTextField? (20 个回答) It's possible i
我使用戴尔 XPS M1710。笔记本电脑的盖子、侧面扬声器和前置扬声器都有灯(3 组灯可以单独调节)和鼠标垫下方的灯。在 BIOS 中,我可以更改这些灯的颜色,至少是每个组。另外,我可以在鼠标垫下打
我知道我可以使用 在 iOS 5 中打开设置应用 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"
我有一个 Django 应用程序,我正在尝试为其设置文档。目录结构如下: - doc - project | - manage.py 我已经设置了路径以便 Sphinx 可以看到东西,但是当我尝试使用
我正在使用 768mb ram 运行 centos 5.5。我一直在日志中获取 server reached MaxClients setting, consider raising the MaxC
我在具有以下配置的服务器内运行了 Drupal 安装: StartServers 5 MinSpareServers 5 MaxSpareServers 15 MaxClien
是否可以使用 Microsoft.Web.Administration 包为给定的 location 配置 asp 设置? 我想以编程方式将以下部分添加到本地 IIS applicationHost.
我一直在阅读为 kube-proxy 提供参数的文档,但没有解释应该如何使用这些参数。我使用 az aks create 创建我的集群使用 azure-cli 程序,然后我获得凭据并使用 kubect
我想知道与在 PHP 中使用 setcookie() 函数相比,在客户端通过 JavaScript 设置一些 cookie 是否有任何明显的优势?我能想到的唯一原因是减少一些网络流量(第一次)。但不是
我有一个按钮可以将 body class 设置为 .blackout 我正在使用 js-cookie设置cookie,下面的代码与我的按钮相关联。 $('#boToggle').on('click'
我有一堆自定义的 HTML div。我将其中的 3 存储在具有 slide 类的 div 中。然后,我使用该幻灯片类调用 slick 函数并应用如下设置: $('.slide').slick({
我正在创建一个应该在 Windows 8(桌面)上运行的应用 我需要: 允许用户使用我的应用启动“文件历史记录”。我需要找到打开“文件历史记录”的命令行。 我需要能够显示“文件历史记录”的当前设置。
我刚买了一台新的 MacBook Pro,并尝试在系统中设置 RVM。我安装了 RVM 并将默认设置为 ➜ rvm list default Default Ruby (for new shells)
由于有关 Firestore 中时间戳行为即将发生变化的警告,我正在尝试更改我的应用的初始化代码。 The behavior for Date objects stored in Firestore
在 ICS 中,网络 -> 数据使用设置屏幕中现在有“限制后台数据”设置。 有没有办法以编程方式为我的应用程序设置“限制后台数据”? 或 有没有办法为我的应用程序调出具有选项的“数据使用”设置? 最佳
我正在尝试使用 NextJS 应用程序设置 Jest,目前在 jest.config.js : module.exports = { testPathIgnorePatterns: ["/.n
我最近升级到 FlashDevelop 4,这当然已经将我之前的所有设置恢复到原来的状态。 我遇到的问题是我无法在新设置窗口的哪个位置找到关闭它在方括号、大括号等之前插入的自动空格的选项。 即它会自动
有没有办法以编程方式访问 iPhone/iPod touch 设置? 谢谢。比兰奇 最佳答案 大多数用户设置可以通过读取存储在 /User/Library/Preferences/ 中的属性列表来访问
删除某些值时,我需要选择哪些设置来维护有序队列。我创建了带有自动增量和主键的 id 的表。当我第一次插入值时,没问题。就像 1,2,3,4,5... 当删除某些值时,顺序会发生变化,例如 1,5,3.
我正在尝试设置示例 Symfony2 项目,如此处所示 http://symfony.com/doc/current/quick_tour/the_big_picture.html 在访问 confi
我是一名优秀的程序员,十分优秀!