How to loop through all of the elements on a specific page?

If you want to loop through all of the items of a specific type on a page, you can use our LOOP command. I have provided an example below that loops through all of the text areas and fills them out with the text "Proof". You can change this example to perform an action or series of actions on all the links, check boxes, etc. on a particular page.

  1. GET_WEB_VALUE HALT textarea_count LOCATOR application.page.textareas.textarea_count NUMBER NA  FALSE _
    • This step gets the count of all of the text boxes on a page and stores the result in textarea_count variable using the GET_WEB_VALUE command
    • Locator application.page.textareas.textarea_count is defined by XPath: count(//table[@class='table']//textarea)
  2. LOOP HALT counter 1 @textarea_count 1
    • This step start the loop from index 1 through the total number of text areas found via step 1 (i.e. textarea_count) and adds 1 to the loop index at each iteration
  3. FILL HALT clear=false application.page.text.generic_text_area "Proof"
    • This step fills out each text area with the word "Proof" using the loop counter @textarea_count defined in step 2
    • Locator application.page.text.generic_text_area is defined as: (//table[@class='table']//textarea)[@counter]
  4. LOOP_END HALT
    • This step ends the loop
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.