【问题标题】:Selenium 2: error: cannot parse capability: chromeOptionsSelenium 2:错误:无法解析功能:chromeOptions
【发布时间】:2015-01-15 10:32:23
【问题描述】:

尝试使用 ChromeDriver 2.9 运行测试时出现以下错误:

未知错误:无法解析功能:chromeOptions org.openqa.selenium.WebDriverException:未知错误:无法解析功能:chromeOptions 来自未知错误:必须是字典 (驱动程序信息:chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86)(警告:服务器未提供任何堆栈跟踪 信息)

这是我的代码:

File file = new File("C:/Users/Desktop/TestSE/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());        
driver = new ChromeDriver();
baseUrl = "http://localhost:8080/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

我还使用以下命令运行我的 selenuim 服务器:

java -jar selenium-server-standalone-2.44.0.jar -Dwebdriver.chrome.driver=chromedriver.exe

我的服务器运行正常(我通过 thsi url 检查了:http://localhost:4444/selenium-server/driver/?cmd=getLogMessages 并且我有“OK”作为消息)

【问题讨论】:

    标签: java google-chrome selenium selenium-webdriver


    【解决方案1】:

    尝试使用此命令为 Chrome 注册节点

    java -jar selenium-server-standalone-2.48.2.jar -role node -hub http://localhost:4444/grid/register -maxSession 15 -browser browserName="chrome",version=ANY,platform=ANY,maxInstances=15 -Dwebdriver.chrome.driver=/path/to/chromedriver
    

    希望对你有帮助

    【讨论】:

      【解决方案2】:
      System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver_win32 \\chromedriver.exe");
          ChromeOptions chromeOptions = new ChromeOptions();
          chromeOptions.addArguments("--headless");
          driver = new ChromeDriver(chromeOptions);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-08-04
        • 2021-12-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多