9 Replies Last post: Jul 9, 2009 7:47 AM by Joan  
Joan Beginner 3 posts since
Nov 29, 2008
Currently Being Moderated

Jun 30, 2009 10:59 AM

Continuing a Java RC script after a window has closed

When you log into OpenCMS, it closes the window you are in, and opens a new one.  With Selenium IDE the close() doesn't work, and everything is fine, but with RC I can't proceed:

 

(in java)

 

click("//input[@value='Login']");

 

After that, every command I try gets a "com.thoughtworks.selenium.SeleniumException: ERROR: Threw an exception: Current window or frame is closed!".  eg selectWindow, openWindow, waitForPopup etc etc.  I can find no way of pointing to the new window, or preventing old one from closing.

 

In IDE the original window doesn't close.

mauricio Beginner 22 posts since
May 22, 2009
Currently Being Moderated
1. Jun 30, 2009 11:13 AM in response to: Joan
Re: Continuing a Java RC script after a window has closed

Hi Joan,

     i don't understand which is the problem specifically.You can't select the new window because you don't have the WindowId? the new window doesn't load?

Could you paste the piece of code?

 

Saludos

Sharon Beginner 3 posts since
Jul 1, 2009
Currently Being Moderated
2. Jul 1, 2009 5:58 AM in response to: mauricio
Re: Continuing a Java RC script after a window has closed

Hi,

 

I was working with Joan on this issue.  When logging into cms there is a login window and a workplace window.  In the IDE the script is able to fully run and log into cms without errors.

 

When running this in ide this works but running as RC in a suite with other tests works randomly. The error message is com.thoughtworks.selenium.SeleniumException: ERROR: Threw an exception: Current window or frame is closed!

 

The problem is there are 2 windows and both are open but it thinks it thinks the workplace window is shut.  How can I get selenium to get focus on the second window?

 

 

<tr>
    <td>open</td>
    <td>/opencms/opencms/system/login</td>
    <td></td>
</tr>
<tr>
    <td>waitForElementPresent</td>
    <td>//form[@id='ocLoginForm']/div/table/tbody/tr[2]/td[2]/b</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>ocUname</td>
    <td>Admin</td>
</tr>
<tr>
    <td>type</td>
    <td>ocPword</td>
    <td>admin</td>
</tr>

 

</tbody></table>
</body>
</html>

mauricio Beginner 22 posts since
May 22, 2009
Currently Being Moderated
3. Jul 1, 2009 8:45 AM in response to: Sharon
Re: Continuing a Java RC script after a window has closed

Sharon,

     To select the windows you use selenium.selectWindow("WindowID"); so you need to get both windows Id.

You must consider that before executing any command. So if you execute Open and the new window is loaded, first you have to select the new window and after that do the WaitForElementPresent.

Maybe you would find useful to look at selenium.WaitForPopup method.

Everytime you need to execute some command or evaluate something on a window you will have to select it first.

Hope this helps.

Saludos

Sharon Beginner 3 posts since
Jul 1, 2009
Currently Being Moderated
4. Jul 1, 2009 9:07 AM in response to: mauricio
Re: Continuing a Java RC script after a window has closed

Hi

 

This doesn't help me since cms doesnt have window ids only window names.  I have tried selecting via window title/window names.  I know this is selenium problem as a previous company I worked in also had this problem with cms systems where it does not recognise 2 windows are open.  Why does this work in ide and not through RC?

anilkumarch Beginner 40 posts since
Jun 3, 2009
Currently Being Moderated
5. Jul 1, 2009 9:24 AM in response to: Joan
Re: Continuing a Java RC script after a window has closed

I think u can do one thing for closing old browser use sel.stop(); and after that u can use sel.start(); for new browser.

So that focus will be there on the new window only.

 

 

 

 

 

 

 

 


selenium.selectWindow("");

selenium.click("link=Logout");

selenium.stop();

 

selenium.start();

selenium.open(http://10.60.5.69:8080/XXXX/index.jsp);

selenium.type("username", "uname");

selenium.type("password", "pass");

 

 

 

 

 

mauricio Beginner 22 posts since
May 22, 2009
Currently Being Moderated
6. Jul 1, 2009 9:37 AM in response to: Sharon
Re: Continuing a Java RC script after a window has closed

If windows doesn't have id selenium automatically allocate one to them.

Use the script below to find out those ids.

 

String script = "var windowId; for(var x in selenium.browserbot.openedWindows ){windowId=windowId + '&' + x;}"

 

As you can see it returns a string with the windows id separated by '&'. Split it and you can handle each window id to select the window.

Sharon Beginner 3 posts since
Jul 1, 2009
Currently Being Moderated
7. Jul 2, 2009 3:07 AM in response to: mauricio
Re: Continuing a Java RC script after a window has closed

Hi

 

We've already tried all this before but it doesn't work.  Still thinks the window is closed.  Has anyone had this problem with content management systems and found the solution.

 

cheers

 

S

More Like This

  • Retrieving data ...