How to of but doesn’t sometimes where no comes from the ?
– Has anyone encountered this issue and how did you address it?
– How can I improve the test so it will always click or tap on the
element?

I’m using tablets and phones.
The test is passing sometimes and failing sometimes.

It is not a bug, because manually testing the app it works.
But I do notice if my screen is sticky or oily due to many fingerprints sometimes I have to tap twice to open up the screen, but on other times I just tap once to open up the screen.

Any ideas?

    Code before this is to capture screenshots and compare if
    video images are different and changing. 
    Followed by if else statement to report if a loading icon 
    is displayed in case of internet connection lost, which
    I noticed a couple of times at this point when tapping fails.


    private boolean pauseVideo() throws InterruptedException {
    Boolean pausefoundnclicked = false;
    WebElement pause_element = null;

    size = driver.manage().window().getSize();
    int y=size.height/2;
    int x=size.width/2;

            Reporter.log("---Tap screen to bring up pause button.", true);
            //driver.tap(1, x, y, 500); (sometimes failing with this so tried to change to TouchAction
            TouchAction touchAction = new TouchAction(driver);
            touchAction.tap(x, y).perform();

            try
            {
                try {
                    pause_element = wait.until(ExpectedConditions.elementToBeClickable(By.id("player_overlay_widget_play_pause")));
                    pause_element.click();
                    Reporter.log("---Found and clicked pause button by id.", true);
                    pausefoundnclicked = true;
                }
                catch (Exception e1)
                {
                    try
                    {
                        pause_element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//android.widget.ImageView[contains(@resource-id, 'player_overlay_widget_play_pause') and @index='1']")));
                        pause_element.click();
                        Reporter.log("---Found and clicked pause button by xpath.", true);
                        pausefoundnclicked = true;
                    }
                    catch (Exception e)
                    {
                        pause_element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[1]/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.RelativeLayout/android.widget.ImageView[2]")));
                        pause_element.click();
                        Reporter.log("---Found and clicked pause button by xpath.", true);
                        pausefoundnclicked = true;
                    }
                }
            }
            catch (Exception e)
            {
                Reporter.log("---Did not find a pause button.", true);
            }


    return pausefoundnclicked;

}



Source link https://sqa.stackexchange.com/questions/35222/how-to-handle-issue-of-intermittently-appium-taps-but--work-sometimes-whe

LEAVE A REPLY

Please enter your comment!
Please enter your name here