jjzjj

java - WebDriverException : Error forwarding the new session cannot find : {platform=WINDOWS, 浏览器名称=FIREFOX,版本=3.6}

coder 2024-04-02 原文

我是 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%

这两个命令都可以正常工作。

我不确定何时何地需要使用命令行 -浏览器 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 -浏览器 browserName=firefox

将xxx替换为实际的ip地址

关于java - WebDriverException : Error forwarding the new session cannot find : {platform=WINDOWS, 浏览器名称=FIREFOX,版本=3.6},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15411078/

有关java - WebDriverException : Error forwarding the new session cannot find : {platform=WINDOWS, 浏览器名称=FIREFOX,版本=3.6}的更多相关文章

随机推荐