0

if i open Chrome via chromedriver and navigate to a URL i only get a data:, in the navigation bar. All googled solutions (right chromedriverversion, protocoll in URL, etc.) didnt help me.

package de.vhv.selenium;

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

public class OpenChromeAndNavigate {

    @Test
    public void test() {
        System.setProperty("webdriver.chrome.driver", "C://vhventw//selenium//chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.google.de");
    }

}

In addition everything works if i add --headless and listen to the debugport. But i dont want to let it run headless.

 package de.vhv.selenium;

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class OpenChromeAndNavigate {

    @Test
    public void test() {
        System.setProperty("webdriver.chrome.driver", "C://vhventw//selenium//chromedriver.exe");
        WebDriver driver = new ChromeDriver(getDesiredCapabilities());
        driver.get("https://www.google.de");
    }

    private ChromeOptions getDesiredCapabilities() {
        ChromeOptions options = new ChromeOptions();


        options.addArguments("--headless");
//        options.addArguments("--disable-extensions"); // disabling extensions
//        options.addArguments("--disable-gpu"); // applicable to windows os only
//        options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
//        options.addArguments("--no-sandbox");
        options.addArguments("--remote-debugging-port=9223");


        return options;
    }

}

Any ideas what i can try?

Setup:

Chrome Version = 71.0.3578.80

Chromedriver Version = 2.46.628402

  • Did you try just passing the default ChromeOptions without any options set? – Bill Hileman Mar 15 '19 at 16:39
  • 1
    This seems to discuss the same issue. You might find an answer in this thread: https://stackoverflow.com/questions/37159684/chrome-opens-with-data-with-selenium – Asyranok Mar 15 '19 at 17:28
  • 1
    @Stephan : Could you please update your chrome driver to latest – Pritam Maske Mar 15 '19 at 17:41
  • Our Chromeversion is 71.0.3578.80 and i cant change it. The downloadpage (http://chromedriver.chromium.org/downloads) says use chromedriver 2.46 with chrome 71. Should i still try chromedriver 74.0.3729.6 ? – Stephan Rehmstedt Mar 18 '19 at 08:43

3 Answers3

2

I figured out, that the line

options.addArguments("--remote-debugging-port=9225");

fixed my problem. I already used it in headless runs to listen to the port and watch the headless run. But it fixed my problem with headfull runs.

return new ChromeDriver(getDesiredCapabilities());



private ChromeOptions getDesiredCapabilities() {
    ChromeOptions options = new ChromeOptions();
    //options.addArguments("--headless");
    options.addArguments("--disable-extensions"); // disabling extensions
    options.addArguments("--disable-gpu"); // applicable to windows os only
    options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
    options.addArguments("--no-sandbox");
    options.addArguments("--remote-debugging-port=9225");

    return options;
}
0

You need to take care of a couple of things:

  • Not sure about your project structure but I will suggest to avoid the . character and the word selenium within the package name as in:

    package de.vhv.selenium;
    
  • The Value part passed through System.setProperty() line containing the absolute path of chromedriver.exe should be expressed through escaped backslashes as:

    System.setProperty("webdriver.chrome.driver", "C:\\vhventw\\selenium\\chromedriver.exe");
    
  • As per ChromeDriver - WebDriver for Chrome:

If you are using Chrome version 72, please download ChromeDriver 2.46 or ChromeDriver 72.0.3626.69

  • As per best practices:
    • Upgrade JDK to recent levels JDK 8u202.
    • Upgrade Selenium to current levels Version 3.141.59.
    • Upgrade ChromeDriver to current ChromeDriver v73.0.3683.68 level.
    • Keep Chrome version between Chrome v73 levels. (as per ChromeDriver v73.0.3683.68 release notes)
    • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
    • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
    • Take a System Reboot.
    • Execute your @Test.
    • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

I was struggling with the same issue, then I realised that I forgot to start the test with :

$I->amOnPage('/');

definitely to try before digging deeper.

LdiCO
  • 577
  • 12
  • 31