Search code examples
javaselenium-webdriverintellij-ideaselenium-chromedriverautomated-tests

java selenium webDriver : method driver.get(url) doesn't work , the browser is open without url


I am new with selenium java. I wrote my first code to open a page using web driver, the browser chrome opened without content

public class WebdriverDemo {
    public static void main(String[] args) {

        String url = "http://www.google.com";
        WebDriver driver = new ChromeDriver();
        driver.get(url);
       //i tried  driver.navigate().to(url); either but it's not working the same result !! 
}
}

pom.xml screenshot1

pom.xml screenshot2

Empty browser launch screen


Solution

  • Just add this part of code:

    ChromeOptions optionss=new ChromeOptions();
    optionss.addArguments("--remote-allow-origins=*");
    WebDriver driver=new ChromeDriver(optionss);