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

java – WebDriverException:转发新会话时出错找不到:{platf

发布时间:2020-12-14 06:08:37 所属栏目:Java 来源:网络整理
导读:我是Selenium Web驱动程序以及Grid 2的新手. 我试图运行测试用例,但它给了我一个例外 Exception in thread main org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : {platform=WINDOWS,browserName=FIREFOX,version=3

我是Selenium Web驱动程序以及Grid 2的新手.

我试图运行测试用例,但它给了我一个例外

Exception in thread “main” org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : {platform=WINDOWS,browserName=FIREFOX,version=3.6}

我已经使用命令启动了一个节点和集线器

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

java -jar selenium-server-standalone-2.29.0.jar -role node  -hub %grid register%

这两个命令都运行正常.

我不确定我何时何地需要使用命令行
?-browser browserName = firefox,version = 3.6,maxInstances = 5,platform = WINDOWS

(试图从Grid 2官方页面配置节点

是因为这个吗?

这是我的代码:

package test;

import java.net.URL;
import java.net.MalformedURLException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class Test { 
    public static void main(String[] args) throws MalformedURLException {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
            capability.setBrowserName("FIREFOX");
            capability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
            capability.setVersion("3.6");
    //  capability.setCapability("");
        WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),capability);
        //WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com"); 

}
}
最佳答案
对于注册节点,使用特定的浏览器配置,您必须在命令提示符下使用以下行:

java -jar selenium-server-standalone-2.32.0.jar -role node -hub http://xxx.xxx.xxx.xxx:4444/grid/register -browser browserName = firefox

将xxx替换为实际的IP地址

(编辑:李大同)

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

    推荐文章
      热点阅读