Skip to content

Close window Problem #360

Closed
Closed

Description

@schwalldorf

If you close a pop-up window using close window, all further Selenium2 keywords fail with an exception:
NoSuchWindowException: Message: Window not found. The browser window may have been closed.
Even keywords as "get window names" fail.
The same problem arises when the pop-up window is closed by mouse click or using Javascript window.close().

Minimal set-up for testing: Simple local html file with
click me

And a simple Robot test with
Open browser test.html
Click button bt1
${windows}= Get Window Names
select window cc
sleep 1s
close window
${windows}= Get Window Names

A "sleep" or "wait until keyword succeeds" after "close window" does not help.

This is not a Selenium issue. If you code the scenario (open and close a pop-up window) in Java and the Java API for Selenium, everything works fine. No exceptions arise.

Set-ups:
OS: Mac OS 10.10 and Windows 7
Browsers: Firefox, Chrome, IE10
Selenium 2.44
Selenium2Library 1.6, 1.5, 1.4

Activity

  1. emanlove commented on Feb 11, 2015

    @emanlove
    Member

    Trying Python Selenium on

    OS: Linux Ubuntu 14.04
    Browsers: Firefox 31.0
    Selenium 2.44
    Selenium2Library 1.6

    Using the test page, test.html

    <html>
      <head>
      </head>
      <body>
        <button id="bt1" onclick='javascript:window.open("https://www.codecentric.de", "cc")'>click me</button>
      </body>
    </html>

    I have no issues with just selenium

    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.get('file:///home/user/test_win_operation/test.html')
    el = driver.find_element_by_id('bt1')
    el.click()
    h = driver.window_handles
    driver.current_window_handle
    # assuming second window
    driver.switch_to.window(h[1])
    driver.close()
    driver.window_handles
    driver.quit()

    but do see the issue with the library (1.6)

    *** Settings ***
    Library  Selenium2Library
    
    #Test Teardown  Close All Browsers
    
    *** Test Cases ***
    Check window issue
      Open browser  file:///home/user/test_win_operation/test.html
      Click button  bt1
      ${windows}=   Get Window Names
      Select Window   cc
      Close Window
      ${windows}=  Get Window Names
  2. emanlove commented on Feb 11, 2015

    @emanlove
    Member

    Just looking into the backlog of issues for any other open/close/switch window related ones. Noting (in no particular order) #205, #340, #213. Not sure if these still valid. Please feel free to add any I have missed. Maybe we can tackle these altogether.

  3. divfor commented on May 10, 2015

    @divfor
    Contributor

    This issue is due to call keyword with 'browser.get_current_window_handle()' right after call 'close window' which will not change current window handle to something else.

    see 6.4 in http://www.w3.org/TR/webdriver/#defining-window-and-frame
    Once the window has closed, future commands must return a status code of no such window until a new window is selected for receiving commands.

  4. self-assigned this
    on May 10, 2015
  5. aaltat commented on Nov 2, 2017

    @aaltat
    Contributor

    The window management keywords have been refactored as part of #968. Therefore I am closing the issue. If problem is still present, please send an update on the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions