selenium: IEDriverServer hangs when getting cookies on newly opened window

Meta -

OS:
Windows 10 (64-bit) and Windows Server 2012 R2 (64-bit) Selenium Version:
3.4.0 Browser:
Internet Explorer Browser Version:

  • Windows 10: 11.413.15063.0 (both 32-bit and 64-bit)
  • Windows Server 2012 R2: 11.0.9600.18538 (both 32-bit and 64-bit)

Expected Behavior -

don’t hang up when getting cookies on newly opened window.

Actual Behavior -

hang up when getting cookies on newly opened window.

Steps to reproduce -

  1. Create WebDriver instance.
  2. open first window by e.g. driver.get()
  3. open another window by e.g. executing JavaScript “window.open()”.
  4. switch to newly opened windw.
  5. try to get cookies.

following Java and python code my reproduce this issue. (python version needs remote IE webdriver stup)

Java:

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class GetCookiesOnAnotherWindow {
    public static void main (String[] args) {
        WebDriver driver = new InternetExplorerDriver();
        try {
            driver.get("about:blank");
            ((JavascriptExecutor) driver).executeScript("window.open('about:blank', 'another_window')");
            driver.switchTo().window("another_window");
            driver.manage().getCookies(); // <- IE Driver hangs here
        } finally {
            driver.quit();
        }
    }
}

Python:

# coding=utf-8
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

try:
    caps = DesiredCapabilities.INTERNETEXPLORER.copy()
    driver = webdriver.Remote(desired_capabilities=caps)
    driver.get("about:blank")
    driver.execute_script("window.open('about:blank','another_window')")
    driver.switch_to.window('another_window')
    cookies = driver.get_cookies() # Hang up HERE.
except Exception:
    pass
finally:
    driver.quit()

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

I still see this. Is this known and open ?

Exception org.openqa.selenium.WebDriverException: Could not retrieve cookies. The most common cause of this error is a mismatch in the bitness between the driver and browser. In particular, be sure you are not attempting to use a 64-bit IEDriverServer.exe against IE 10 or 11, even on 64-bit Windows

any solution? I am getting the same issue