-2

In the below code, the browser got opened but the URL is not typed by the script. Can anyone please suggest me the corrections needed for this script?

package SeleniumDemo;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class S {

public static void main(String[] args) throws Exception {
    System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
    WebDriver  DRIVER = new ChromeDriver();
    String URL = "http://www.facebook.com";
    DRIVER.manage().window().maximize();
    DRIVER.get(URL);
    System.out.println(DRIVER.getTitle());
    DRIVER.close();
    }
}
Suraj Gautam
  • 1,524
  • 12
  • 21

2 Answers2

0

System.setProperty should point to you chrome driver location not chrome application

0

In your code you have specified wrong path of chromedriver.exe. It should be chromedriver.exe not chrome.exe. Also, check your chrome browser version and based on that download chromedriver to execute your program.

    System.setProperty("webdriver.chrome.driver", "path of chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("https://www.facebook.com/");
    System.out.println("Page title is: " + driver.getTitle());

You can download chromdriver from below location:

https://chromedriver.chromium.org/downloads

SeleniumUser
  • 4,065
  • 2
  • 7
  • 30