2

I am getting org.openqa.selenium.remote.SessionNotFoundException: session null does not exist exception while trying to open google.com through IE driver.

My code is as follows:

public class Google {
    static WebDriver obj;

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String browser = "ie";

        if (browser.equalsIgnoreCase("chrome")) {
            System.setProperty("webdriver.chrome.driver", "E:\\Selenium\\Selenium Prerequisites\\chromedriver.exe");
            obj = new ChromeDriver();

        } else if (browser.equalsIgnoreCase("firefox")) {
            obj = new FirefoxDriver();
        } 
        else if (browser.equalsIgnoreCase("ie")){
            System.setProperty("webdriver.ie.driver", "E:\\Selenium\\Selenium Prerequisites\\IEDriverServer.exe");
            obj = new InternetExplorerDriver();

        }
        else
            System.out.println("invalid browser name");

        obj.get("https:\\google.com");
    }
}

Please let me know where I am missing, I am using IE browser v11, selenium webdriver v2.53.1, IEDriverServer v3.6.0 32bit.

Below is full exception which I am getting (Please note that if I switch to selenium webdriver v3.6, then there is no issue and code is working perfectly):

Started InternetExplorerDriver server (64-bit)
3.6.0.0
Listening on port 37910
Only local connections are allowed
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: session null does not exist (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'SHAN', ip: '192.168.1.6', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{capabilities={acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0, ie.ensureCleanSession=false, elementScrollBehavior=0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:37910/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, ignoreProtectedModeSettings=false}, browserName=internet explorer, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss, platformName=windows, setWindowRect=true}, sessionId=280ec1bf-328c-42f6-8f46-e5e7a1dc47f5, platform=ANY}]
Session ID: null
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:316)
    at webDriverInitialTest.Google.main(Google.java:54)

Below are the screenshots from IE security tab.

enter image description here

enter image description here

enter image description here

enter image description here

Thanks.

Mark Amery
  • 110,735
  • 57
  • 354
  • 402
Shan
  • 69
  • 1
  • 2
  • 10
  • Make sure you have done all the setting in IE like zoom level and security settings. If not then first do configure and try – NarendraR Oct 08 '17 at 08:03
  • @NarendraR, which security settings you are talking about. I am new to selenium so have few knowledge. Could you please let me know for which setting you are talking about? My above code is perfectly working for chrome & firefox but only getting issue in IE. – Shan Oct 08 '17 at 08:06
  • lookout here http://www.seleniumeasy.com/selenium-tutorials/how-to-run-webdriver-in-ie-browser – NarendraR Oct 08 '17 at 08:10
  • can u replace below code and let me know `DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); capabilities.setCapability(CapabilityType.BROWSER_NAME, "IE"); capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); System.out.println("Starting InternetExplorer........"); System.setProperty("webdriver.ie.driver","src/test/resources/IEDriverServer.exe"); driver = new InternetExplorerDriver(capabilities); driver.manage().window().maximize(); driver.get(TestDataComman.baseURL);` – NarendraR Oct 08 '17 at 08:15
  • Getting same exception. I have used below code in elseif condition for ie driver.`DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); capabilities.setCapability(CapabilityType.BROWSER_NAME, "IE"); capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); System.out.println("Starting InternetExplorer........"); System.setProperty("webdriver.ie.driver","E:\\Selenium\\Selenium Prerequisites\\IEDriverServer.exe"); obj = new InternetExplorerDriver(capabilities); obj.manage().window().maximize();` – Shan Oct 08 '17 at 08:34
  • See this also : https://stackoverflow.com/questions/29642940/unable-to-open-ie11-driver-instance-using-selenium-webdriver-with-java – iamsankalp89 Oct 08 '17 at 08:46

3 Answers3

1

Do it manually

Set same Security level for all zones. Try this steps

  • Open Internet Explorer Browser
  • Go to menu and open Tools -> Internet Options -> Security
  • Set all values of zones (Internet, Local intranet, Trusted sites, Restricted sites) to the same protected mode, enabled or disabled should not matter
  • click on OK.

or use this

DesiredCapabilities IEcaps = DesiredCapabilities.internetExplorer();

IEcaps .setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);

WebDriver driver = new InternetExplorerDriver(IEcaps );
iamsankalp89
  • 4,242
  • 2
  • 12
  • 35
0

Apart from setting the Protected mode enabled or disabled for all the 4 zones, you will need to set the zoom level to 100% in Internet Explorer.

0

To launch the IE11 using selenium WebDriver use the IEDriverServer_Win32_3.4.0 version and latest selenium webDriver. It works for IE11 You can get the IE driver 3.4.0 in the below link http://selenium-release.storage.googleapis.com/index.html?path=3.4/

Also add the below snippet to your code to ignore the protected mode settings of IE and set the path for IEDriverServer in your code

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); 
capabilities.setCapability(InternetExplorerDriver.
INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);    
String driverpath="src/Drivers/IEDriverServer.exe"; //IEDirver path
System.setProperty("webdriver.ie.driver",driverpath);
InternetExplorerDriver driver= new InternetExplorerDriver(capabilities);
Leviand
  • 2,567
  • 3
  • 24
  • 35