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

Appium fails to find element from video player while content is playing. #8525

Closed
ajeeshvl opened this issue May 25, 2017 · 6 comments
Closed

Comments

@ajeeshvl
Copy link

ajeeshvl commented May 25, 2017

The problem

I'm trying to to automate play back controls in a video player. When appium tries to find element during playback, it hangs and throw No Such Element Exception. Same works, when the content playback is paused.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.6.4
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: Mac OS (Sierra) 10.12.4
  • Node.js version (unless using Appium.app|exe): v7.3.0
  • Mobile platform/version under test: Android 7.1.1 / 6.0.1
  • Real device or emulator/simulator: Real device
  • Appium CLI or Appium.app|exe: Appium CLI

Details

I tried xpath to find element, still did not work. Also changes automation-name as uiautomator2. Nothing worked

**Error Message :**Selenium::WebDriver::Error::NoSuchElementError: An element could not be located on the page using the given search parameters.

Link to Appium logs

https://gist.github.com/ajeeshvl/aebd97d5aa9e8da66b5861b0233e53d5

@mykola-mokhnach
Copy link
Collaborator

mykola-mokhnach commented May 25, 2017

This is XCTest issue and Appium cannot do anything about it. To workaround the problem you might try to pause the playback, cache control coordinates and then click by coordinates while video playback is active instead of trying to locate the element. You can either use TouchActions or mobile: interface to perform click by absolute coordinates.

@ajeeshvl
Copy link
Author

@mykola-mokhnach I'm facing this issue on android though. As a work around, I pause the video and try to find elements. I also tried automation-name as uiautomator2, still above problem exists.

@mykola-mokhnach
Copy link
Collaborator

As far I know Android waits until the app under test is idle before to execute element location, so this suggestion will be true for Android as well except of mobile: interface.

@InfantAnto
Copy link

Thanks @mykola-mokhnach for the suggestion. I've added the following helper methods and did the trick.

public static int[] getElementCoOrdinates(WebElement element) {
        Point location = element.getLocation();
        int x = location.getX();
        int y = location.getY();

        return new int[] {x, y};
    }

    public static void tap(AppiumDriver driver, int[] coOrdinates) {
        TouchAction action = new TouchAction(driver);
        action.tap(PointOption.point(coOrdinates[0], coOrdinates[1])).perform();
    }

But we can find video player control elements only before the video started playing. If it once started playing or then paused case as well once started, the screen will not be idle (it will continuously triggered events). But in my case I've an option to pause the video at the beginning (say autoplay disable option).

So I've done the following steps. (In my case I need to click on the mute button once started playing)

  1. Get the element at the beginning - before the video started playing (Say mute button)
  2. Get the mute element's co-ordinates
  3. Click on the play button (we can able to get play button as well before started playing)
  4. And then click (tap) on the mute button by using TouchAction by passing coordinates since this action has no contact with the uiautomator viewer

NOTE:
Appium UiAutomator viewer will not be able to find the element when the video started playing (when screen is not idle).

@InfantAnto
Copy link

And one more thing is most of we peoples would faced the same issue with android uiautomator viewer when trying see the elements for adding page object.

Error:

UI hierarchy Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist

I just did the workaround for viewing the elements when screen is not idle.
We can able to view the elements on the screen using
driver.getPageSource() method. These combinations are helped me to solve this issue.

@lock
Copy link

lock bot commented Feb 28, 2020

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.

@lock lock bot locked and limited conversation to collaborators Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants