Selenium IDE Tutorial For "assertSelectedIndex" And "assertSelectedIndexes"

There are many tutorial posts available related to selenium IDE assert commands to use them in your software web application regression test case. Let we discuss two more assertion commands - "assertSelectedIndex" And "assertSelectedIndexes". Both of these are working with single select or multi-
select software application page elements like drop down and list box. These are good assertions to verify that your targeted label index or indexes are selected or not. You can view 2 related "assertSelectedId" and "assertSelectedIds" command examples 

"assertSelectedIndex" Command
"assertSelectedIndex" command will verify that your targeted element's selected label's index is same as expected? It will return error like '[error] Actual value '3' did not match '0'' if targeted and expected index values did not match else it will be pass. This command will not work with multiple selected labels.

"assertSelectedIndexes" Command
"assertSelectedIndexes" command will work same as "assertSelectedIndex" command but for multiple selected indexes too. Let we see example for both these commands.

New Test
CommandTargetValue
openhttp://only-testing-blog.blogspot.com/2013/09/testing.html
addSelectionname=FromLBlabel=Mexico
assertSelectedIndexname=FromLB3
addSelectionname=FromLBlabel=India
addSelectionname=FromLBlabel=USA
addSelectionname=FromLBlabel=Spain
assertSelectedIndexesname=FromLB0,3,4,8

Run above example in selenium IDE. First "assertSelectedIndex" command will be pass because current selected label Mexico's index will match with expected index 3. "assertSelectedIndexes" command will be fail and return error like '[error] Actual value '0,3,4,7' did not match '0,3,4,8''. Replace expected value text from '0,3,4,8' to '0,3,4,7' to get it pass.

This way you can put assertion for selected indexes in your software application regression testing script.

No comments:

Post a Comment