Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetPageSource On UIScrollView Is Slow #14048

Closed
ajschwieterman opened this issue Mar 10, 2020 · 2 comments
Closed

GetPageSource On UIScrollView Is Slow #14048

ajschwieterman opened this issue Mar 10, 2020 · 2 comments
Labels

Comments

@ajschwieterman
Copy link

ajschwieterman commented Mar 10, 2020

The problem

There is a page in the iOS app I am testing where it displays a list of items that it receives from a backend server. I am using driver.getPageSource() to know when the page is done loading on the phone's screen and if a scroll down action is performed, the bottom of the scroll view has been reached. When I call driver.getPageSource(), Appium takes a really long time to load the page source, sometimes up to 30 seconds. Any other suggestions/method to accomplish these tasks?

Environment

  • Appium version (or git revision) that exhibits the issue: v1.16.0
  • Desktop OS/version used to run Appium: Mac OS Catalina v10.15.3
  • Node.js version (unless using Appium.app|exe): v13.7.0
  • Npm or Yarn package manager: v6.13.7
  • Mobile platform/version under test: iOS v13.3.1
  • Real device or emulator/simulator: Real device
  • Appium CLI or Appium.app|exe: Appium CLI

Code To Reproduce Issue [ Good To Have ]

public static void waitForPageToLoad() {
      //Variables
      String originalPageSource = "";
      String newPageSource = getPageSource();

      while (!originalPageSource.equals(newPageSource)) {
          originalPageSource = newPageSource;
          newPageSource = driver.getPageSource();
      }
}

private static MobileElement scrollToElement(MobileElement element) {
        //Variables
        boolean isElementVisible = false;
        String newPageSource = "";
        String originalPageSource;
        boolean reachedBottomOfPage = false;

        newPageSource = getPageSource();
        while (!isElementVisible && !reachedBottomOfPage) {
            //Check if the element is visible
              ...
              /* code to check if the element is visible */
              ...
            //If the element isn't visible, scroll down the page
            if (!isElementVisible) {
                originalPageSource = newPageSource;
                scrollDown();
                newPageSource = driver.getPageSource();
                reachedBottomOfPage = (originalPageSource.equals(newPageSource));
                if (isResultsRecordingEnabled) {
                    enableRecordingResults();
                }
            }
        }
        return element;
    }
@mykola-mokhnach
Copy link
Collaborator

Yes, you could try to get the source with some attributes excluded (I would try to exclude the visible one first): #13595 (comment)

Also, setting the source type to description is pretty fast, since it uses a native XCTest call

@ajschwieterman
Copy link
Author

Thank you for your help! The issue that you linked was very helpful. I was able to cut my test time significantly! 👏 👍 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants