Selenium IDE "assertSelectedId" and "assertSelectedIds" Commands With Example

Most of all software web applications contains list box or drop downs on web page and "assertSelectedId" and "assertSelectedIds" commands are very useful to verify and assert the ids of selected label/s from list box. Both these are very good alternatives of "assertSelectedIndex", "assertSelectedIndexes",
"assertSelectedLabel" commands. You can view few related verification commands like "verifySelectedId", "verifySelectedLabel", "verifySelectedValues" and MANY MORE.

"assertSelectedId" Command
"assertSelectedId" command check and assert if selected label's id is same as expected id or not. If both are same then this command will pass else it will return error like '[error] Actual value 'country3' did not match 'country4'' in execution log and selenium IDE will stop execution.

"assertSelectedIds" Command
"assertSelectedIds" command works same as "assertSelectedId" command but for multiple selected labels. Run bellow given example in your selenium IDE window and verify result.

New Test
CommandTargetValue
openhttp://only-testing-blog.blogspot.com/2014/01/textbox.html
addSelection//select[@name='FromLB']label=Japan
assertSelectedIdFromLBcountry3
addSelection//select[@name='FromLB']label=Germany
assertSelectedIdsFromLBcountry3,country6
assertSelectedIds//select[@name='FromLB']country3,country7

First "assertSelectedId" command will pass because on this stage, selected label's actual and expected id are same. Frist "assertSelectedIds" command will pass too. Second "assertSelectedIds" command will fail and selenium IDE will stop its execution.

No comments:

Post a Comment