加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

selenium-webdriver – 在Windows上设置Selenium Grid 2

发布时间:2020-12-14 02:27:20 所属栏目:Windows 来源:网络整理
导读:我在 Windows 7上设置了Selenium Grid 2(selenium-server-standalone-2.1.0)(我也尝试过Windows Server 2008)64位.我在本地测试WebDriver,一切都很顺利. 我用以下方式启动集线器: java -jar selenium-server-standalone-2.1.0.jar -role hub 为FireFox添加w
我在 Windows 7上设置了Selenium Grid 2(selenium-server-standalone-2.1.0)(我也尝试过Windows Server 2008)64位.我在本地测试WebDriver,一切都很顺利.

我用以下方式启动集线器:

java -jar selenium-server-standalone-2.1.0.jar -role hub

为FireFox添加webDriver节点可以正常工作,但Google Chrome等其他任何内容都会引发IllegalOperation异常.

例如:

我尝试为Chrome添加节点:

java -jar selenium-server-standalone-2.1.0.jar -role webDriver -hub http://127.0.0.1:4444 -browser browserName = chrome platform = windows version = 12 -port 5556

当您转到http://localhost:4444/grid/console时,这将显示为集线器上的节点

我添加代码来调用webDriver,例如:

DesiredCapabilities capability = new DesiredCapabilities();
            capability.SetCapability(CapabilityType.Platform,"windows");
            capability.SetCapability(CapabilityType.Version,"12");
            capability.SetCapability(CapabilityType.BrowserName,"chrome");

            IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),capability);

我几乎立即得到一个例外:

{“找不到:{platform = windows,browserName = chrome,version = 12}”}

似乎甚至没有找到节点.我是新手,这是我在设置中遗漏的东西? (Internet Explorer也是如此,不断变化的版本似乎没有帮助).

我已经搜索了几个小时和几个小时但没有任何匹配异常的东西似乎与我的问题一样通用.

解决方法

IllegalOperation Exception {“找不到:{platform = windows,browserName …是由没有匹配功能引起的(它永远不会到达节点).

如果我在启动明确声明平台和浏览器的节点时使用配置文件,例如:

{
"capabilities":
        [
                {
                        "browserName":"firefox","maxInstances":1
                },{
                        "browserName":"chrome","platform":"WINDOWS",{
                        "browserName":"internet explorer","version":"9","maxInstances":1
                }
        ],"configuration":
        {
                "cleanUpCycle":2000,"timeout":30000,"proxy":"org.openqa.grid.selenium.proxy.WebDriverRemoteProxy","maxSession":5,"url":"http://[myIP]/wd/hub",}
}

并使用此行启动集线器:
java -jar selenium-server-standalone-2.2.0.jar -role webdriver -nodeConfig myconfig.json -hub http:// [myIP]:4444 / grid / register

并创建如下功能:

DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability(CapabilityType.Platform,"WINDOWS");
capability.SetCapability(CapabilityType.BrowserName,"internet explorer");

然后测试工作(您必须将IE中的所有区域设置为受保护的方式).注:我注意到Windows在WINDOWS中是大写的,否则你会收到错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读