Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
Add Comment
Please, Sign In to add comment