Thursday, 8 October 2015

Select commands

                                                       Select commands


Working And Handling Multiple Windows In Selenium IDE

Working with the multiple windows in selenium IDE is not hard. Many selenium IDE users asking me for this question so let me try to explain it. You need to handle multiple windows many time of software applications regression testing using selenium IDE or any other tools. As you all knows, selenium IDE is not too much
powerful tool compared to others software testing tools like Webdriver,we have to handle few things manually in selenium IDE. Bellow given case is not fully recorded but updated few commands manually after recording. Let we look at the example.

New Test
CommandTargetValue
openhttp://www.bing.com
storeTitlei
openWindowhttps://www.google.com
pause5000
selectWindowGoogle
clickAndWaitcss=#gb_2 > span.gbts
storeTitlej
selectWindow${i}
clickAndWaitcss=#scpt1 > a
storeTitlei
selectWindow${j}
closej
selectWindow${i}
close


Handling Multiple Windows Test case explanation :
  • Selenium IDE will open 'bing' home page.
  • "storeTitle" will store bing home page title in variable 'i' to reuse it latter.
  • "openWindow" will open Google home page in new window and next pause command will pause selenium IDE for 5 secs.
  • Now we want to do some actions on newly opened window but we can not do any thing directly in new window. First of all we have to select new window. Next "selectWindow" command will select new window of Google home page.
  • Next command will click on Google's image link.
  • Now suppose i want to do some actions on parent 'bing' home page window. Before selecting parent window, "storeTitle" command will store latest title of page in variable 'j' so It will help selenium IDE to find this child window again when you want to perform some action on it.
  • Next commands will select parent 'bing' window and click on image link. (You can do more actions here.)
  • "selectWindow" command will select child window and next close command will close popup window.
  • Last 2 commands will do same thing on parent window.
Keep one thing in mind during navigating between multiple windows of software application - Before leaving current selected window, Always store latest window title of your current selected window and then select other windows. You can try above case with some other sites.

Selenium "verifySelectOptions", "verifySelectedLabel" and "verifySelectedIndex" Example

"verifySelectOptions", "verifySelectedLabel" and "verifySelectedIndex" commands works with drop down list box or multi select list box. Let me explain all of three first and then will see them with example.

Selenium IDE "verifySelectOptions" Command
"verifySelectOptions" command used for verification of list box option values. It will show error message if
defined values not available in list box. You can also use it for verification of option values. If not found match then selenium will return error message in log.

Using "verifySelectedLabel" Command in Selenium
As name suggect, "verifySelectedLabel" command will verify the name of selected label. If not found then selenium will return error message in log.

Selenium "verifySelectedIndex" Command
Every label contains index value in drop down and you can verify correct indexed label selection using "verifySelectedIndex" command. Let we see all three commands with example.

New Test
CommandTargetValue
openhttp://only-testing-blog.blogspot.in/2013/09/testing.html
verifySelectOptionsname=FromLBUSA,Russia,Japan,Mexico,
India,Germany,Italy,Spain,
Malaysia,Greece
verifySelectOptionsname=FromLBRussia,Japan,Mexico,
India,Germany,Italy,Spain
selectname=FromLBlabel=Russia
verifySelectedLabelname=FromLBIndia
verifySelectedLabelname=FromLBRussia
verifySelectedIndexname=FromLB1
verifySelectedIndexname=FromLB5



In above example, all three commands inserted 2 times. one with incorrect value and one with correct value.
  • 1st "verifySelectOptions" command will pass because Actual value 'USA,Russia,Japan,Mexico,India,Germany,Italy,Spain,Malaysia,Greece' will match with targeted value 'USA,Russia,Japan,Mexico,India,Germany,Italy,Spain,Malaysia,Greece'.
  • 2nd "verifySelectOptions" command will Fail.
  • 1st "verifySelectedLabel" will be fail because current selected label 'Russia' will not match with 'India'.
  • 2nd "verifySelectedLabel" will be pass.
  • 1st "verifySelectedIndex" command will pass
  • 2nd "verifySelectedIndex" command will be fail because label 'Russia' has index = 1.
________________________________________________________________

No comments:

Post a Comment