Google Search

Friday, October 18, 2013

Working with Pop-up windows in Selenium IDE - Day 5

New windows which open from a link within a website move the actual focus from the frame you are recoding, so it is very important to move back to original website and continue recording.

Let us take an example of a website which has an embedded link, opening a new website.



You can get the code for a sample webpage containing a pop-up window from below link


Activities done on the code:
1.       Opening webpage.
2.       Clicking on link (opening a pop-up window) & waiting for pop-up for 30 secs.
3.       Store titles of all windows
4.       Check the window title names using echo command.
5.       Selecting the window, you need to work on.
6.       Working on the selected window (clicking a link).
7.       Verify title of refreshed page.

Selenium, code for above activities looks like below:



Let us understand the code below:

Line 1 – opening the website using ‘open’ command.
Line 2 – Clicking the link on the website which opens the embedded link in Website 1
Line 3 – waitForPopUp command waits for the pop up window to open for time mentioned in value column.
Line 4 – storeAllWindowTitles, store the title of all the windows open in a variable j
Line 5 – echo will display the value of variable j, i.e. the title of all windows open.
Line 6 – selectWindow command will select the window with title HTML Help (as mentioned in Target)
Line 7 – click on one of the link on the web page

Line 8 – verifyTitle verifies the title of window as HTML Tutorial.

No comments:

Post a Comment