0

I'm a newbie with Selenium WebDriver. I found some sample code, and adapted it a little bit to get my own test program. I'm having trouble with it! Here's the program:

package test;

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

public class SeleniumTester {
    public static void main(String[] args) {
       try {
           System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\Selenium\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();
           driver.get("http://www.oddsportal.com/");
           driver.manage().window().maximize();
           String str = driver.getCurrentUrl();
           System.out.println("The current URL is " + str);
       }
       catch (Exception ex) { 
           System.out.println("Encountered exception in SeleniumTester.main() :");
           System.out.println(ex.getMessage());
       }
   }
} 

It compiles fine, and starts running, first outputting some diagnostics:

"Starting ChromeDriver (v2.9.248315) on port 11716
October 25, 2017 6:11:22 IP. 
org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS"

But then, at the line "driver.get(...);" an exception occurs :

"Encountered exception in SeleniumTester.main() :
unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"8164.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=61.0.3163.100)
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:40.131Z'
System info: host: 'DESKTOP-47EFBCO', ip: '192.168.43.83', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, chrome={userDataDir=C:\Users\Ilkka\AppData\Local\Temp\scoped_dir12200_17489}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=61.0.3163.100, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, platformName=XP, cssSelectorsEnabled=true}]
Session ID: 31a4a5806225e18533805ed0fbbca392"

Something about invalid context. What does it mean? How to fix it? Should I perhaps use a different constructor to create the ChromeDriver? Ideas, anyone?

5
  • Most likely the issue is because of an older version of chromedriver. Download a newer version of chromedriver and try giving its path. Commented Oct 25, 2017 at 16:23
  • A quick search pointed to questions like stackoverflow.com/questions/41832859/… Commented Oct 25, 2017 at 16:28
  • I downloaded version 2.33 of chromedriver.exe from chromedriver.storage.googleapis.com/index.html?path=2.33. And now my test program works! In other words, it opens the oddsportal.com front page and displays it in a maximized Chrome window. Thanks a lot for your advice, Atul! Commented Oct 25, 2017 at 16:41
  • Glad to help. Will add it as answer. Please accept it. And then maybe vote for the question to be closed. Commented Oct 25, 2017 at 16:49
  • Possible duplicate of Selenium: Runtime.executionContextCreated has invalid 'context': Commented Oct 25, 2017 at 17:01

1 Answer 1

0

Most likely the issue is because of an older version of chromedriver. Download a newer version of chromedriver and try giving its path.

The browser version and driver version compatibility issues could cause this issue. The chromedriver page mentions the driver compatibility for browser version. For example, as of now, the page lists:

Latest Release: ChromeDriver 2.33 Supports Chrome v60-62

Sign up to request clarification or add additional context in comments.

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.