Selenium IDE "storeElementIndex" and "verifyElementIndex" Commands Examples

"storeElementIndex" and "verifyElementIndex" Commands are used for store and verify index of an element node respectively. If you want to verify the placement sequence of an element on the page then you need to use "storeElementIndex" or "verifyElementIndex" or "assertElementIndex" command. It will return index of
targeted element. Relative index of element is calculated from its parent node starting from 0. Means 1st element has 0 index and 2nd element has index=1. Let we try to understand with example of software application

Selenium IDE "storeElementIndex" Command
"storeElementIndex" command will calculate and store targeted element's index in given variable. Bellow example will help you to understand it better.

"verifyElementIndex" Command
"verifyElementIndex" command will check and verify an index of element and return error like '[error] Actual value '2' did not match '1'' if specified index of element will not match with actual index.

New Test

In above example,
'Xpath=//input[@type='search']' is xpath of search text box.
'Xpath=//select[@id='searchLanguage']' is xpath of language drop down.
'Xpath=//input[@class='formBtn']' is xpath of Search button.
  • 2nd "storeElementIndex" command will store index of search text box(1) in to variable 'i'.  (Note : You can view element's indexing position using firebug.).
  • 3rd "storeElementIndex" command will store index of language drop down(2) in to variable 'j'.
  • 4th "storeElementIndex" command will store index of Search button(2) in to variable 'k'.
  • 8th "verifyElementIndex" command will verify actual index of search text box with value stored in variable 'i'. It will pass.
  • 9th "verifyElementIndex" command will verify actual index of language drop down with value stored in variable 'i'. It will fail and return '[error] Actual value '2' did not match '1'' in log.
  • 10th "verifyElementIndex" command will verify actual index of Search button with value stored in variable 'k'. It will pass.
This way you can automate your element indext store and verification of any software web application.

1 comment:

  1. Nice Post with information regarding great use! The ways you have illustrated the information is impressive. Thanks!

    software development company india