Forum Discussion

lydincamilleri's avatar
lydincamilleri
Occasional Contributor
2 years ago

Mobile - Swipe to an element

Hello!

I am trying to find a way how I can scroll in an application until an element is visible.

 

Basically the original issue is that using app.FindElementByXpath of an object errors with "Unable to find an element that matches the specified 'xpath' selector strategy", however, it works when I manually scroll onto the object.

 

On web, I am aware of the ScrollIntoView functionality, but can't find anything similar for android/ios?

 

Thanks in advance!

3 Replies

  • markos's avatar
    markos
    Occasional Contributor

    I'm interested in the possibilities and workarounds here. It seems like a messy hack to scroll down one screen-full at a time, checking for the target control every time.

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      As the initial post mentions FindElementByXpath(), it is my guess that the talk is about web page rendered on mobile.

      If my guess is correct, than ScrollIntoView() must work as it seems to be supported by all browsers.

      The case might be that due to lazy-loading of page, sought-for element might not exist in page DOM until this element is not rendered (not requested from the server).

      If this is the case, then screen-by-screen scroll with the check whether or not the sought-for element appeared in page DOM seems to be the only reliable way of implementation that I know.

       

  • markos's avatar
    markos
    Occasional Contributor

    I interpreted the original post as asking about usage of the Appium mobile app library, not browser-based features. Because they said, "On web, I am aware of the ScrollIntoView functionality, but can't find anything similar for android/ios?"

    Sometimes it is hard to tell from the docs which functions can work in both Appium and Selenium.