Guest User

Untitled

a guest
Aug 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. private boolean pauseVideo() throws InterruptedException {
  2. Boolean pausefoundnclicked = false;
  3. WebElement pause_element = null;
  4.  
  5. size = driver.manage().window().getSize();
  6. int y=size.height/2;
  7. int x=size.width/2;
  8.  
  9. Reporter.log("---Tap screen to bring up pause button.", true);
  10. //driver.tap(1, x, y, 500); (sometimes failing with this so tried to change to TouchAction
  11. TouchAction touchAction = new TouchAction(driver);
  12. touchAction.tap(x, y).perform();
  13.  
  14. try
  15. {
  16. try {
  17. pause_element = wait.until(ExpectedConditions.elementToBeClickable(By.id("player_overlay_widget_play_pause")));
  18. pause_element.click();
  19. Reporter.log("---Found and clicked pause button by id.", true);
  20. pausefoundnclicked = true;
  21. }
  22. catch (Exception e1)
  23. {
  24. try
  25. {
  26. pause_element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//android.widget.ImageView[contains(@resource-id, 'player_overlay_widget_play_pause') and @index='1']")));
  27. pause_element.click();
  28. Reporter.log("---Found and clicked pause button by xpath.", true);
  29. pausefoundnclicked = true;
  30. }
  31. catch (Exception e)
  32. {
  33. 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]")));
  34. pause_element.click();
  35. Reporter.log("---Found and clicked pause button by xpath.", true);
  36. pausefoundnclicked = true;
  37. }
  38. }
  39. }
  40. catch (Exception e)
  41. {
  42. Reporter.log("---Did not find a pause button.", true);
  43. }
  44.  
  45.  
  46. return pausefoundnclicked;
  47.  
  48. }
Add Comment
Please, Sign In to add comment