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
CommandTargetValue
openhttp://only-testing-blog.blogspot.com/2013/09/testing.html
addSelectionname=FromLBlabel=Germany
assertNotSelectedLabelname=FromLBIndia
removeSelectionname=FromLBlabel=Germany
addSelectionname=FromLBlabel=India
assertNotSelectedLabelname=FromLBIndia

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.

Example

New Test
CommandTargetValue
openhttp://only-testing-blog.blogspot.com/2013/09/testing.html
addSelectionname=FromLBlabel=Italy
addSelectionname=FromLBlabel=Germany
assertNotSelectedLabelsname=FromLBIndia,Italy
removeSelectionname=FromLBlabel=Germany
addSelectionname=FromLBlabel=India
assertNotSelectedLabelsname=FromLBIndia,Italy

7 comments:

  1. Hello,
    can any one please help me...
    I want to run an entire test suite(not a single test case) continuously using selenium ide...
    Is it possible?

    ReplyDelete
  2. You can do it by clicking on 'Run Entire Test Suite' button of selenium IDE. Find more info at http://software-testing-tutorials-automation.blogspot.in/2011/10/how-to-use-selenium-ide-toolbar.html

    ReplyDelete
  3. thank you for your post. It was very helpful.

    ReplyDelete
  4. addselection command not working can any one please explain

    ReplyDelete
  5. Hello,

    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?

    ReplyDelete
    Replies
    1. 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

      Delete
  6. I logged on to a website with ID & Password. Here the browser is prompting for 'Save Password or Cancel'. I selected 'Cancel' and this is one time activity.

    Selenium is throwing an error here.

    How to code it in such scenario ?

    Please let me konw.

    ReplyDelete