Pages

Selenium IDE - How "assertNotSelectedLabel" and "assertNotSelectedLabels" commands works

"assertNotSelectedLabel" and "assertNotSelectedLabels" are very useful assertions in selenium IDE software for drop down and list box type elements. However you can look at other related commands examples on this Link. As you know, If any of the above assert command will fail, selenium IDE will stop

its execution immediately. However in case of verification commands, Selenium IDE will continue its execution even if that verify command will fail. So this is the main difference between "assert" and "verify". You can Take a Selenium IDE Online Test which will helps you for selenium IDE interview preparation. Let me come to the point, we need to look at practical examples of "assertNotSelectedLabel" and "assertNotSelectedLabels" commands.

"assertNotSelectedLabel" Command

"assertNotSelectedLabel" is works with drop down or list box for single selected label. It will fail if selected label string will match with expected label string. Else it will be pass.

Example

New Test

Command

Target

Value

open

http://only-testing-blog.blogspot.in/2013/09/testing.html

addSelection

name=FromLB

label=Germany

assertNotSelectedLabel

name=FromLB

India

removeSelection

name=FromLB

label=Germany

addSelection

name=FromLB

label=India

assertNotSelectedLabel

name=FromLB

India

Look in to above example, First "assertNotSelectedLabel" command will become pass because actual value will not match with expected value. But last"assertNotSelectedLabel" command will fail. Run both examples in selenium IDE to confirm its function.

"assertNotSelectedLabels" Command

"assertNotSelectedLabels" command works same as "assertNotSelectedLabel" command but it is supporting multiple labels too. It will return error like '[error] Actual value 'India,Italy' did match 'India,Italy'' if both values will match.

In real time(banking proj) in which scenario do we use assertNotSelectedLabel/assertNotSelectedLabels? I understood that in dropdowns we use this command and if actual and expected matches it fails .But what is the purpose of using it ?Are we checking whether the options that is selected through add selection is shown as selected?

Consider scenario -> Sometimes, When you are loading or redirecting to some page. On page redirection, You your condition Is some labels should be selected or should not selected before performing any action on that page. In such situation, You need these commands