0

I am a newbie to selenium web driver.I have a test written in java which is to be tested using Selenium web driver. I ran the test class as a java application.I wrote the following snippet of code to obtain the instance of the ChromeDriver. I get the following message for the following code snippet.

    @Override
    public WebDriver get() {
        log.info("Creating Chrome driver");
        try {
            return new ChromeDriver(buildCapabilities());
        } catch (IOException e) {
            throw new ExceptionInInitializerError(e);
        }
    }

Also have the path to the ChromeDriver set

private static final String CHROME_DRIVER = "chromedriver.exe"; URL chromeDriverUrl = getClass().getResource("/" + CHROME_DRIVER); String pathToChromeDriver = chromeDriverUrl.getPath(); System.setProperty("webdriver.chrome.driver", pathToChromeDriver);

IMAGE: enter image description here

Do not understand as to why the following message is displayed on the return new ChromeDriver(buildCapabilities()) line of code.

4 Answers 4

1

to use chrome driver you need to download chrome driver from here

and then use the chrome driver by

System.setProperty("webdriver.chrome.driver", "C:/Users/Hussain/Desktop/selenium-2.30.0/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
Sign up to request clarification or add additional context in comments.

1 Comment

@Sanika Joshi : I hope it serves you problem
0

Well, for starters, ChromeDriver (and FireFox driver) are both RemoteWebDrivers, not WebDrivers. Those types are not compatible. As for why you're getting a firefox driver instead of a chrome one, I'm guessing that your either your buildCapabilities() function or your remote grid is returning a firefox driver.

Comments

0

Very simple change. Reimporting my project into the IntelliJ evironment fixed the problem. Reimport symbol in Intellij

Comments

0

you may also try using bonigarcia

   <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>5.3.2</version>
        </dependency>
  private WebDriver webDriver;

     public WebDriver getDriver(){
        ChromeOptions options = new ChromeOptions();
        WebDriverManager.chromedriver().setup();
        options.addArguments("--remote-allow-origins=*", "ignore-certificate-errors");
        webDriver = new ChromeDriver(options);
        return webDriver;
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.