2

I just start learning Selenium, but it seems that my ChromeDriver version is incompatible with my current Chrome version? Any help would be appreciated:

The following is the error message I got:

Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1556601048.968][SEVERE]: Unable to receive message from renderer
org.openqa.selenium.SessionNotCreatedException: session not created
from disconnected: Unable to receive message from renderer
  (Session info: chrome=74.0.3729.108)
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17763 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 17.07 seconds
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'

My original code:

package com.selenium.webdriver.basic;

import java.util.concurrent.TimeUnit;

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

public class First { /** * webdriver is a thing where all my functions are * which is going to control the browser * and manages the functions which will let me the browser's property */ WebDriver driver;

public void invokeBrowser() {
    try {
        System.setProperty("webdriver.chrome.driver", "C:\\Selenium_tutorial\\chromedriver_win32\\chromedriver.exe");
        driver = new ChromeDriver();  //instantiate your chrome driver
        driver.manage().deleteAllCookies();//use driver as object reference
    //  driver.manage().window().maximize(); //always minimize by default

        //bait synchronization. always need this 
        driver.manage().timeouts().implicitlyWait(3600, TimeUnit.SECONDS); //element detection timeout
        driver.manage().timeouts().pageLoadTimeout(3600, TimeUnit.SECONDS);


        driver.get("https://www.google.ca/");
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
public static void main(String[] args) {
    // TODO Auto-generated method stub
    First myObj = new Fisrt();
    myObj.invokeBrowser();

}

}

Giacomo1968
  • 58,727

1 Answers1

0

This would work as-is with older versions of Selenium, but you should add one line and modify another to use ChromeOptions. I'm doing this "air code" so it might not be 100% accurate:

ChromeOptions option = new ChromeOptions();
driver = new ChromeDriver(options);

You should be prompted by your IDE to include the library for ChromeOptions, I don't know what it is off the top of my head or I'd include that for you, too.

Also, while page and element timeouts are important, you're setting both to one hour - way too long for a timeout failure. I recommend setting them to something more realistic, like 15 to 30 seconds.

Giacomo1968
  • 58,727
Bill Hileman
  • 802
  • 7
  • 10