Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Application crashed when a popup window closed #1167

Closed
lukeis opened this issue Mar 2, 2016 · 37 comments
Closed

Application crashed when a popup window closed #1167

lukeis opened this issue Mar 2, 2016 · 37 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 1167

What steps will reproduce the problem?
1.Click a link get a popup window
2.switch to the popup window,the popup window have one button named save. Click the
button, the popup window closed.But the application crashed
3.Try to switch back to the orginal window

This only appears in IE. Firefox works fine.
What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?

Beta 1 .net bings. OS: Window 7 64bit/ Windows xp sp3
Browser:IE

Please provide any additional information below.
   var webdriver = new InternetExplorerDriver();
            var selenium = new WebDriverBackedSelenium(webdriver, "http://10.86.1.104/");
            selenium.Start();
            selenium.Open("");
            selenium.WindowMaximize();
selenium.Click("//div[@id='ctl00_radMenu']/ul/li[1]/a/span"); //Popup appears
selenium.SelectWindow("name=PartnerSelection");     
            selenium.Click("ctl00_ContentPlaceHolder1_button_Save");//Crash here
            Thread.Sleep(1000);
selenium.SelectWindow("null");




Reported by binken.zou on 2011-01-06 07:36:05

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm also facing the same issue using IE with RemoteWebDriver. It throws a java.exe error
and crashes the RemoteWebDriver server

Reported by aidanfoley.louth on 2011-01-07 11:52:38

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Is this only happening with the 1.x (Selenium RC) API? The WebDriverBackedSelenium class
is not well-tested in .NET. 

Reported by james.h.evans.jr on 2011-01-07 12:35:21

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I am looking at the the WebDriverBackedSelenium source code. I think this situation
not only occurs in 1.x API, but also the Webdriver API.

Reported by binken.zou on 2011-01-07 12:48:02

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 1188 has been merged into this issue.

Reported by simon.m.stewart on 2011-01-20 16:51:56

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by jari.bakken on 2011-01-27 11:04:42

  • Labels added: Component-WebDriver, Browser-IE

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm seeing the same issue.

Selenium 2.0a4
Windows 7.0.5730.11
Firefox 3.6.13.


- I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when
processing request: The server localhost failed to respond
- Retrying request
FAILED CONFIGURATION: @BeforeMethod setUp
org.openqa.selenium.WebDriverException: Session has no driver: 543b8644-cf76-452d-b75c-956d75148e74
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version:
'1.6.0'
Driver info: driver.version: remote
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:94)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:327)
    at org.openqa.selenium.firefox.FirefoxDriver.execute(FirefoxDriver.java:191)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:186)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:55)
    at com.gsicommerce.webstore.utilities.Action.link(Action.java:568)
    at com.gsicommerce.webstore.selenium.pages.acctmgmt.RegisterNewTemplatePage.clickSaveAndCloseBtn(RegisterNewTemplatePage.java:41)

Reported by gkkothapalli on 2011-01-31 16:59:01

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Please retry with 2.0b1 and let us know if it's still a problem.

Reported by simon.m.stewart on 2011-01-31 17:10:58

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I am using the latest version. And I got this issue!

Reported by binken.zou on 2011-02-01 02:33:29

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I kind of resolve this problem doing this:

1: find a element in my main page.
2: generate the popUp window
3: use seleniumDriver.switchTo().window(yourPopUpWindow);
4: close de window using java.awt.Robot, simulating "Alt + F4"
5: iterate the Set seleniumDriver.getWindowHandles(), searching the element that i
get in the fist step. If a exception is not throw, I call seleniumDriver.switchTo().window(window
in the for);

Is not pretty, but works. And i think only works for windows OS... 

Reported by piratamoendobateria on 2011-02-16 12:18:05

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

This happens to me with the FirefoxDriver.
A pop up is opened, and I click the button that closes it. Then I can do no further
action. Everythiing results in:

org.openqa.selenium.WebDriverException: Session has no driver: 4f5e60f6-f1c6-4367-909f-72b9b9e3dae3

the log: http://pastebin.com/ZnuUJ5Rk

Reported by leo.lathspell on 2011-04-12 23:30:56

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

My workaround:

String mainWindow = driver.getWindowHandle();
driver.findElementById(buttonToOpenPopUp).click();
driver.switchTo().window(popupName);
driver.findElementById(buttonToClosePopUp).clic();
SeleniumSingleton.INSTANCE.switchTo().window(mainWindow);

Reported by leo.lathspell on 2011-04-13 01:08:09

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I am getting the same error.

If you, for example open a window with some radio options, and you need to close the
window when the radio gets clicked, when clicking in the option the exceptions is thrown.


I'm using selenium through capybara. Do you guys know if there is a workaround?

Reported by andre.java on 2011-04-28 20:34:12

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I meet this error too.

I click the button to close the window and the button executes the self.close().

IE can't work, but Firefox(3.x.x) works well. 

Reported by maplesept on 2011-05-09 06:21:03

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

This works for me in IE using the WebDriver API. Is it only the RC API that exhibits
the problem?

Reported by james.h.evans.jr on 2011-05-10 13:18:39

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

My workaround is saving the windowHandle of the main window:
    String mainWindowHandle = webDriver.getWindowHandles().iterator().next();

Open your new window and do something with it. To close it call:

    ((JavascriptExecutor) browser.getWebDriver()).executeScript("window.close()");
    webDriver.switchTo().window(mainWindowHandle);

Reported by alportac on 2011-05-19 10:30:27

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

or to close it you can simply do:
webDriver.switchTo().window(newWindowHandle);
webDriver.close()
webDriver.switchTo().window(mainWindowHandle);

Reported by hirsh.dan on 2011-05-29 09:22:47

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Even I was facing the same issue with Firefox. Comments mentioned in 15 has worked out.

Reported by sreelu.nr on 2011-06-28 10:04:44

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Hello I got the same issue and i don't understand what you mean here :  browser.getWebDriver()).executeScript("window.close()");
                               Whats browser instance is ? I'm noob in java & i Like
to understand things others things why iterator in this declaration :             
                             String mainWindowHandle = webDriver.getWindowHandles().iterator().next();
 Thanks all^^

Reported by toowave on 2011-06-30 13:45:40

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Ok i resolve my issue by closing all windows and popup just after i use them and by
allowing more memory to the JVM

Reported by toowave on 2011-07-01 08:14:09

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I am having the same problem (with Firefox 3.6.18) using a WebDriverBackedSelenium instance
that uses a RemoteWebDriver (Java API).  I reproduce the problem using the following
sequence:

1) click a link that opens pop-up window
2) driver.switchTo().window("Pop up window name");
3) driver.close();

I can use the workaround in comment 15 to prevent Firefox from crashing.  Feel free
to contact me directly if you need more info.

Reported by 3M8455 on 2011-07-07 20:35:26

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I am having the same problem with following setup:
Firefox 5.0.1 
selenium-java-2.1.0.jar

WebDriverBackedSelenium selenium;
selenium.selectWindow(null);
selenium.click(link);//PopUpWindow is opened
selenium.selectWindow(newWindow);
selenium.closeWindow(newWindow);
selenium.selectWindow(null);

The workaround in comment 15 also works for me. Code now looks like:
WebDriverBackedSelenium selenium;
selenium.click(link);//PopUpWindow is opened
String mainWindowHandle = selenium.getWrappedDriver().getWindowHandles().iterator().next();
selenium.selectWindow(newWindow);
selenium.closeWindow(newWindow);
selenium.getWrappedDriver().switchTo().window(mainWindowHandle);

Reported by david.badstuebner@xcom.de on 2011-07-21 09:01:40

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by david.burns@theautomatedtester.co.uk on 2011-08-31 12:15:42

  • Labels added: Lang-Java
  • Labels removed: Browser-IE

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Im also facing a similar issue with the firefox driver, where a click in a script-opened
popup closes the current popup window and adds some data to the parent page (hence
programatically closing the popup is impossible) that I wish to assert is there, but
the driver fails with

Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Session
has no driver: 34c75cfc-bb55-4c96-a172-698d595a1b11

Reported by torgeir.thoresen on 2011-10-14 13:20:25

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Still getting this in FF8 and Se 2.11. 

Reported by errajasankarchem on 2011-11-14 06:11:16

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

@23: Are you switching back to the initial window handle after the popup has closed?

Reported by jari.bakken on 2011-11-14 12:49:37

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

@jari: I believe I was, yes.

Reported by torgeir.thoresen on 2011-11-14 15:01:46

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by barancev on 2011-11-19 22:05:35

  • Labels added: Component-WebDriverBackedSelenium
  • Labels removed: Component-WebDriver

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I did a further debugging found that, this occurs if I use driver.switchTo().defaultContent();
and driver.switchTo().window(); sequentially this issue happens in Webdriver. If I
use either one, it works correct. 

Reported by errajasankarchem on 2011-12-05 10:19:03

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Here is the solution:-

mainhandle = None
        for handle in self.selenium.window_handles:
            if not mainhandle:
                mainhandle=handle
            else :                 
               self.selenium.switch_to_window(handle)
         self.selenium.switch_to_window(mainhandle) 




Reported by saurabh@snapstick.com on 2012-05-08 13:47:35

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I've also had this problem, using WebDriver with Arquillian. The above suggestions were
not applicable to my situation. My workaround was to spawn another thread just before
the WebDriver click action to close the popup window, which is the point where it freezes
and control is lost, and after a short wait, to switch back to the main window in the
second thread. This solution works for me.

Reported by katie@codemiller.com on 2012-08-22 00:44:53

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

This doesn't seem to be resolved. When I click a button which submits a form in a pop
up, I lose the browser resource and it throws an error.

Happens for me when using Capybara. I need to be able to click a button on this pop
up or I cannot test the work flow (requires me to submit the "OK" button in the pop
up in order to continue)

Reported by DocterJ208 on 2012-11-14 16:00:49

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Is this still an issue? Can anyone provide a reproduction scenario using pure selenium,
without capybara or arguillian? Instead of "Session has no driver" more specific NoSuchWindowException
should appear now in the case you forgot to switch back to the main window.

Reported by barancev on 2013-01-22 09:06:18

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I get this NoSuchWindowException.

org.openqa.selenium.NoSuchWindowException: Window not found. The browser window may
have been closed.

    String mainWindow = driver.getWindowHandle();

    openPopupButton.click();
    String popUpWindow = driver.getWindowHandles().iterator().next();

    driver.switchTo().window(popUpWindow);

    closePopUpButton.click();  // -> Window not found exception

    driver.switchTo().window(mainWindow);

How can I switch the window before the exception occurs?

Reported by vomi1011 on 2013-01-22 16:19:16

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

@vomi1011: This issue is related to WebDriverBackedSelenium, do you have problems with
WDBS or pure WebDriver API?

If you have problems with WebDriver API please raise a new issue and provide a reproduction
scenario that *must* include a sample page. We can't understand why you get exception
without looking at the page code.

Reported by barancev on 2013-01-22 18:50:13

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm sorry, I don't have a problem with WDBS.
I saw the component: "WebDriv...Selenium" and thought it is a thread for the WebDriver
API.

I got this exception in a pageObject, but now it works fine.

Reported by vomi1011 on 2013-01-23 09:07:44

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm closing the issue, it should be fixed by now -- instead of "Session has no driver"
a more specific NoSuchWindowException should appear in the case you forgot to switch
back to the main window.

Please ask to reopen if it is still bothering you.

Reported by barancev on 2013-02-22 15:54:44

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 18:11:49

  • Labels added: Restrict-AddIssueComment-Commit

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant