HOWTO: Selenium IDE Post to New Window(Tab)

      No Comments on HOWTO: Selenium IDE Post to New Window(Tab)

Selenium IDE is a very good tool for automated testing.  But when dealing with multiple windows, you may encounter some problems.  Especially when posting a form to a named target that results in another window.  Just like the following one:

Selenium will not be able to find the new window using commands such as selectWindow and waitForPopUp.  I guess the reason is that, Selenium watches new window open by intercepting the window.open function call, but those windows caused by form posting does not go through window.open.  To continue automated testing in the new window, we need solve this problem.

Here is the workaround.

Instead of waiting new window to be opened by form posting, we can open the target window in advance.  That is firing the following command before form submission.

Later, when the form posts to target postto, the browser will not further open a new window, instead, it will post to the already existing window postto.  Then will can wait for the document to be ready.

But, …, there is another version!

Instead of opening a window with the same name in advance, we can tell Selenium the named window later.  That is, instead of calling the open before form submission, we can call open after submission.  This method is very useful in that sometimes we do not know the name of a window before form submission.  The name may be dynamically generated by a script, etc.  However the name is often available by some scripting instruments.  For example, if you have a form form.  You generated a random target for it.  Then in Selenium command, you can obtain that target like the following:

Wish it helps!

Leave a Reply

Your email address will not be published. Required fields are marked *