使用我的代码时:
DesiredCapabilities caps = new DesiredCapabilities(); DesiredCapabilities.chrome();
caps.setCapability(CapabilityType.BROWSER_NAME, "Firefox"); caps.setPlatform(Platform.WINDOWS);
caps.setCapability(FirefoxDriver.MARIONETTE, value);
WebDriver driver = new RemoteWebDriver(new URL("localhost:4444/wd/hub"), caps);
driver.get("google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("BrowserStack");
element.submit();
System.out.println(driver.getTitle());
driver.quit();
我收到以下错误:
Unable to create new remote session. desired capabilities = Capabilities [{platform=WINDOWS}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
在selenium控制台窗口中,在命令提示符下我收到此错误:
Unable to create new instances on this machine. 18:01:04.489 INFO - Driver class not found: com.opera.core.systems.OperaDriver 18:01:04.490 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
18:01:04.499 INFO - Driver provider org.openqa.selenium.safari.SafariDriver
registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=,
platform=MAC}] does not match the current platform VISTA
2017-01-06:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
... 1 more
18:01:11.703 WARN - Exception: The best matching driver provider
org.openqa.selenium.edge.EdgeDriver can't create a new driver instance for
Capabilities [{platform=WINDOWS}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19
-0700'
您能否告诉我我的代码中的问题在哪里?
答案 0 :(得分:0)
您正在设置Chrome功能DesiredCapabilities.chrome();
,并在接下来的行中设置Firefox功能caps.setCapability(CapabilityType.BROWSER_NAME, "Firefox"); caps.setCapability(FirefoxDriver.MARIONETTE, value);
您甚至想要创建哪个驱动程序?