Selenium Issue" Current window or frame is closed!"

1,882 views
Skip to first unread message

subhabrata...@gmail.com

unread,
Nov 8, 2011, 12:10:35 PM11/8/11
to Selenium Users
Hello ,
I have some problems with main page selection after pop up window
closing .
Getting fallowing error : com.thoughtworks.selenium.SeleniumException:
Current window or frame is closed!

selenium.getAllWindowIds(); returns me array with two “undefined”
elements
tried to use selenium.selectWindow(null); and
but outcome is not positive

I will be very glad if anybody help me to resolve this problem.

selenium.click("link=Add Address to Recipient");
selenium.waitForPopUp("NewWindow", "30000");
selenium.selectWindow("NewWindow");
//dealing with popup window
selenium.click("//input[@value='Update']"); //popup window is closed
by pressing this element
selenium.selectWindow(null);
selenium.waitForPageToLoad("30000");

Mike

unread,
Nov 8, 2011, 6:31:45 PM11/8/11
to Selenium Users
Strange that you should post this now, because that is exactly what I
was coming to ask about. I am using 2.5.0 with
WebDriverBackedSelenium to do this. Here is my code (I have been
experimenting with it a bit):

selenium.click(DOTN_Data.VIEW_TRANS_MENU_PRINTER_FRIENDLY_DETAIL);
selenium.waitForPopUp("_blank", "30000");
selenium.selectWindow("pdftrans.cfm (application/pdf Object)");
//selenium.selectPopUp("_blank");
selenium.close();
Reporter.log("Current window title: '" + selenium.getTitle() + "'",
true);

I originally recorded this using the IDE and the selectWindow used to
be the commented out selenium.selectPopUp("_blank") and I swear it
worked when played back there.

I added the Reporter.log() line to see if it had switched back to the
main window, because doing a selenium.selectWindow(null) was throwing
an exception. If I comment out that line and let it proceed to the
next routine (my @AfterSuite method that logs off from the site) it
fails at the first line in there, which is also doing a
selenium.getTitle() as it turns out.

This window is a PDF file being displayed by the Acroread plug-in on
Windows in Firefox, in case that matters.

Here is my stack trace from doing the getTitle() after I have closed
the pop up window:

com.thoughtworks.selenium.SeleniumException: Component returned
failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED)
[nsIDOMJSWindow.setTimeout]
Build info: version: '2.5.0', revision: '13516', time: '2011-08-23
18:29:57'
System info: os.name: 'Windows Vista', os.arch: 'x86', os.version:
'6.0', java.version: '1.6.0_27'
Driver info: driver.version: unknown
Build info: version: '2.5.0', revision: '13516', time: '2011-08-23
18:30:44'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
at
org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:
41)
at
org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:
38)
at
org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:
170)
at
org.openqa.selenium.WebDriverCommandProcessor.getString(WebDriverCommandProcessor.java:
141)
at
com.thoughtworks.selenium.DefaultSelenium.getTitle(DefaultSelenium.java:
431)
at dotn_helper.LoginAndLogoff.testLogout(LoginAndLogoff.java:167)
at current.Current.testFinish(Current.java:160)

So the big question for me is how do I get switched back to the main
window after closing the pop up window?

Or am I supposed to switch back first and close the pop up window some
other way.

A side issue is that when I try to do a screen capture of the pop up
window all I get is an empty frame, but I imagine that is because it
can't capture an image from acroread, correct?

Mike

On Nov 8, 9:10 am, "subhabrata.banerje...@gmail.com"

swaathi gags

unread,
Nov 8, 2011, 10:19:48 PM11/8/11
to seleniu...@googlegroups.com
Hi,
 
You just try to get all window Names and after the popup closed, you can give selenium.selectWindow("The main window name") instead of null.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.




--
Regards,
swaathi.

Mike

unread,
Nov 9, 2011, 1:17:51 PM11/9/11
to Selenium Users
Your suggestion sounds reasonable, but I am afraid it doesn't work. I
have a couple of methods I use for logging exceptions during a test,
one of which dumps all the various IDs I can get before it outputs a
screen capture and the stack trace (which it does by calling the other
routine that only does the screen capture and stack trace). I use it
so I can debug unexpected errors when writing the new code. So I
modified my original code to look like this:


selenium.click(DOTN_Data.VIEW_TRANS_MENU_PRINTER_FRIENDLY_DETAIL);
selenium.waitForPopUp("_blank", "30000");
selenium.selectWindow("pdftrans.cfm (application/pdf
Object)");
helper.handleExceptionReport("PDF report window open",
null);
selenium.close();
helper.handleExceptionReport("PDF report window
closed", null);
selenium.selectWindow("View Transactions");
Reporter.log("Current window title: '" +
selenium.getTitle() + "'", true);

Here is the output (Note that the string I pass is being output after
the IDs it finds):
Window Titles:
'View Transactions'
'pdftrans.cfm (application/pdf Object)'

PDF report window closed


PDF report window closed

As you can see, it shows no window titles after the selenium.close()
is done. Interestingly enough it does not crash on the
selenium.selectWindow method, but rather on the selenium.getTitle in
the line after that. Remember, in case it matters, I am using
WebDriverBackedSelenium here.

Also, the Firefox itself crashes in the VM and offers to let me debug
it. I would attach the image here, if I could, but the web posting
interface does not allow that.

Here is the stack trace:

com.thoughtworks.selenium.SeleniumException: Connection refused:
connect
Build info: version: '2.5.0', revision: '13516', time: '2011-08-23
18:30:44'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
at
org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:
41)
at
org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:
38)
at
org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:
170)
at
org.openqa.selenium.WebDriverCommandProcessor.doCommand(WebDriverCommandProcessor.java:
100)
at
com.thoughtworks.selenium.DefaultSelenium.selectWindow(DefaultSelenium.java:
351)
at current.Current.testDOTN_CUR_VT_002(Current.java:357)


Mike

Gourav Nahata

unread,
Nov 9, 2011, 5:03:20 PM11/9/11
to seleniu...@googlegroups.com
HI ....

I faced the same issue .In this case  can u please try

String s[ ] = Selenium.selectAllwindownames();
//close the top most window   which is your pop up using command

selenium.close(s[s.length-1 ]);

// now  select main window/previous one

selenium.selectWindow( "" );   // instead of null try this for main window






Thanks
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.




--
Gourav Nahata
HCL Great Britain Ltd.
Hemel Hempstead,
UK

Mike

unread,
Nov 9, 2011, 6:34:04 PM11/9/11
to Selenium Users
Hi Gouray,

I am using 2.5.0 with the Java interface. I took a look and there is
no selectAllwindownames method, nor is there a close method that takes
a string argument. Just in case I double checked the 2.11.0 client
sources and it isn't there, either. Is what you are showing possibly
C# code?

Mike

Mike

unread,
Nov 9, 2011, 7:11:43 PM11/9/11
to Selenium Users
Okay, this is more serious than I thought. On the off chance it was
an issue with Firefox 5 I switched to using IE8, which runs on the
same VM.

Running IE8 with the same test I seem to have crashed Java in the
RemoteWebDriver server window. Poof! Gone with the wind. I am using
Java 1.6_27 there. So I am going to have to do some playing around to
figure out just what is going on here. First, I will upgrade my JVM
to the current version (1.6_29 - not sure if 1.7 is safe to use for
Selenium) and see if that has any effect on the problem.

The second thing will be to update to 2.11.0, which I know has a whole
bunch of bug fixes in it since 2.5.0.

I will report my results back to this thread tomorrow.

BTW - I was able to get FF5 to end up int he debugger for Visual
Studio, but it was less than helpful. All it could tell me was that
there was an uncaught exception.

Mike

Mike

unread,
Nov 10, 2011, 6:26:55 PM11/10/11
to Selenium Users
I have submitted a new issue for this problem:
2820: Able to crash the JVM (1.6_29) using Selenium 1.5.0 to 1.12.0

http://code.google.com/p/selenium/issues/detail?id=2820&thanks=2820&ts=1320967353

I was using 2.5.0 and upgraded to 2.11.0 and now 2.12.0 and they all
have the same problem. With FF5 I can crash Firefox due to an
uncaught exception (according to Visual Studio debugger). With IE8 I
actually get the JVM running the server to crash (due to reading an
address of 0, again according to the Visual Studio debugger). Opera
actually worked.

Details are in the bug for those interested.

Mike
Reply all
Reply to author
Forward
0 new messages