I have a page which has links that used onclick="gotoLocation" to scroll to an element elsewhere on the page.

I know I can use storeElementPositionLeft and storeElementPositionTop to get the element's position (and manually scroll to it through storeEval and scrollTo), but how do I confirm that the page has actually scrolled to the element or not?

We are using Selenium IDE (not Webdriver).

  • I would try seeing if the element is visible Apr 4 '18 at 11:32

but how do I confirm that the page has actually scrolled to the element or not?

If you use the Kantu Selenium IDE's visual ui testing feature, you can use its VisualAssert command. As the name suggests, it compares an image (screenshot) of the element with whatever is on the browser screen when the test is run:

  • if the image is found => test passed
  • if the image is not found => test failed

In this use case, the default search are of viewport works just right for you.


Use selenium to check the elements visibility

The element may exist but if not visible, this will show that.
If the element is present but not visible it can show that.

You can use WebElement.isDisplayed()

Be aware though that an element needs to be both visible and enabled, i.e.

public bool IsElementVisible(IWebElement element)
    return element.Displayed && element.Enabled;

JavascriptExecutor je = (JavascriptExecutor) driver; // now execute query which actually will scroll until that element is not appeared on page. je.executeScript("arguments[0].scrollIntoView("@id"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.