Skip to content

How do I get the required element into viewport

This example demonstrates how to bring an element into viewport.

In the solution shown below, you will see that the "Calculate" button is brought into viewport in HICC using "scrollToView" command.

Solution:

# Command Target Value
Launch Application
1 scrollToView xpath=(//div[@id='btn_calculateControls']/a)[1]
 


Tips, Tricks, Gotchas & Best Practices:  

  • As an alternative to "scrollToView" command, you can use scrollToViewAndWait command. This command waits for the element to scroll.
  • When you want to scroll an element which is not at the bottom of the page, it is recommended to perform the scroll action on the element that is preceding to the actual/required element which you want to bring into viewport.
  • You can also mention the position where the element has to scroll using the keywords 'middle/center' or 'top' or 'bottom' and the number of scrolls to be preformed for the positions 'top' and 'bottom' using the separator '||' in the value field.
  • After scrolling the element it is recommended to verify whether the element is in the viewport using assertVisible, verifyVisible or waitForVisible commands.

Feedback and Knowledge Base