DesiredCapabilities in Selenium 3.0 showing error on chrome

时间:2016-10-20 19:25:18

标签: selenium selenium-webdriver

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);


    }

}

I am using Selenium 3.0 and the above code is showing the following error

enter image description here

Can any one please point me to resolve this or provide any workarounds. Thanks

1 个答案:

答案 0 :(得分: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);

我下载了正确的驱动程序并正确指定了路径