question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

scroll to element only scrolls one screen

See original GitHub issue

when using js.executeScript(“mobile: scroll”, scrollObject) instead of scrolling to element only one scroll is performed. If object is in the bottom and you need to scroll more than once to see it than scroll doesn’t get to the object.

Environment

  • Appium version1.5.0
  • Last Appium version that did not exhibit the issue 1.4.16
  • Desktop OS/version used to run Appium:10.11.13
  • Node.js version (unless using Appium.app|exe):v5.8.0
  • Mobile platform/version under test:iOS
  • Real device or emulator/simulator:Real devices iOS8/9
  • Appium

Create a gist which is a paste of your full Appium logs, and link them here. Do not paste your full Appium logs here, as it will make this issue very long and hard to read! If you are reporting a bug, always include Appium logs!

Code To Reproduce Issue [ Good To Have ]

public void scrollToListItemElement(MobileElement scrollToElement, MobileElement optionalOverlappingElement) {

        int initialHeight = scrollToElement.getCenter().getY();
        JavascriptExecutor js = driver;
        String webElementId = scrollToElement.getId();

        HashMap<String, String> scrollObject = new HashMap<>();
        scrollObject.put("element", webElementId);
        scrollObject.put("direction", "down");
        js.executeScript("mobile: scroll", scrollObject);

    }

Please remember that, with sample code; it’s easier to reproduce bug and much faster to fix it.

Please git clone https://github.com/appium/sample-code and use one of your favourite languages and sample apps to reproduce issue.

In case a similar scenario is missing in sample-code, please submit a PR with one of the sample apps provided. Archive.zip

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
imurchiecommented, Apr 5, 2016

Scrolling to an element is no longer supported in Appium 1.5. mobile: scroll with an element scrolls on that element. That is why it does nothing when called again. Try using mobile: scroll without the element, checking if the element is visible and re-scrolling if not.

element = find_element()
while (element.is_not_visible) {
    scroll down
}
0reactions
lock[bot]commented, Apr 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to scroll to an element inside a div? - Stack Overflow
Method 1 - Smooth scrolling to an element inside an element ... To scroll an element into view of a div, only if...
Read more >
Element.scroll() - Web APIs - MDN Web Docs
Chrome Edge scroll Full support. Chrome61. Toggle history Full support. Edge79. T... options.behavior parameter Full support. Chrome61. Toggle history Full support. Edge79. T... options.left parameter Full...
Read more >
Scroll an element into the center of the viewport - Hidde's blog
Say your page displays a list of names and you want a certain person to be highlighted and scrolled into view. There's a...
Read more >
How to Make a Div Stick to the Top of Screen when Scrolling ...
This snippet will help you to make a stick to the top of the screen when you scroll the page. Find out how...
Read more >
Window sizes and scrolling - The Modern JavaScript Tutorial
DOM elements have their current scroll state in their scrollLeft/scrollTop properties. For document scroll, document.documentElement.scrollLeft/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found