2016-10-20 31 views
0
package com.sb.testpackage1; 

import org.openqa.selenium.Platform; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.chrome.ChromeDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.ie.InternetExplorerDriver; 
import org.openqa.selenium.remote.DesiredCapabilities; 

public class DesiredCapabilitiesDemo { 

    public static void main(String[] args) { 

     String baseURL = "http://www.google.com"; 
     WebDriver driver; 

     System.setProperty("webdriver.gecko.driver", "C:\\Users\\m12345\\Downloads\\geckodriver-v0.11.1-win64\\geckodriver.exe");  
     DesiredCapabilities caps = DesiredCapabilities.chrome(); 
     caps.setBrowserName("chrome"); 
     caps.setPlatform(Platform.WINDOWS); 
     driver = new ChromeDriver(caps); 

     driver.manage().window().maximize(); 
     driver.get(baseURL); 


    } 

} 

我使用硒3.0和上面的代碼顯示了以下錯誤DesiredCapabilities硒3.0顯示對鉻錯誤

enter image description here

任何一個可以請點我解決這個或提供任何變通辦法。由於

+0

http://stackoverflow.com/questions/39922071/selenium-getting-error這裏是另外一個與此類似,除了努力啓動一個IE瀏覽器 – sbolla

回答

0
System.setProperty("webdriver.chrome.driver", "C:\\Users\\m12536\\Downloads\\chromedriver_win32\\chromedriver.exe");   
    DesiredCapabilities caps = DesiredCapabilities.chrome(); 
    caps.setBrowserName("chrome"); 
    caps.setPlatform(Platform.WINDOWS); 
    driver = new ChromeDriver(caps); 

    System.setProperty("webdriver.ie.driver", "C:\\Users\\m12354\\Downloads\\IEDriverServer_x64_3.0.0\\IEDriverServer.exe"); 
    DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); 
    caps.setBrowserName("internet explorer"); 
    caps.setPlatform(Platform.WINDOWS); 
    driver = new InternetExplorerDriver(caps); 

我有正確的驅動程序下載並正確地指定的路徑