2017-01-09 57 views
0

当使用我的代码:得到错误,同时运行硒电网

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' 

在硒控制台窗口,在命令提示符下,我得到这个错误:

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

您设置的镀铬能力DesiredCapabilities.chrome();和下一行的Firefox capabilites caps.setCapability(CapabilityType.BROWSER_NAME, "Firefox"); caps.setCapability(FirefoxDriver.MARIONETTE, value);

什么驱动你甚至想创建?