Hi Rajesh,
I have changed code for waiting element
Still to click on Pause button takes 19 seconds.
WebDriverWait wait = new WebDriverWait(driver,3, TimeUnit.SECONDS.toMillis(20));
**
* Play/ Pause Video Player
*/
public void videoPlayPause(){
startTime = new Timestamp(System.currentTimeMillis());
System.out.println("\tPlay/ Pause video process started : " + endTime);
By START_STOP_VIDEO_BUTTON = By.xpath("//android.widget.Button[@text='Play']"); // Appium found
//By START_STOP_VIDEO_BUTTON = By.xpath("//android.widget.Button[@bounds='[187,824][231,858]']"); // Appium found
//By START_STOP_VIDEO_BUTTON = By.xpath("//android.widget.Button[@instance='0']"); // Appium found
videoPlayPauseElement = getElementDetails(START_STOP_VIDEO_BUTTON);
videoPlayPauseElement.click();
endTime = new Timestamp(System.currentTimeMillis());
getProcessTime(startTime, endTime);
System.out.println("\tPlay / Pause video process completed : " + endTime);
}
/**
* Get Element details
* @param by
* @return
*/
private static WebElement getElementDetails(By by){
WebElement element = null;
boolean isElementExist = false;
//System.out.println("\tElement to be find: " + by.toString());
while(!(isElementExist)) {
isElementExist = isElementFound(by);
if(isElementExist){
element = driver.findElement(by);
} else {
wait.until(ExpectedConditions.visibilityOfElementLocated(by));
}
System.out.println("\tElement visibility status: " + isElementExist + " Timestampe: " + new Timestamp(System.currentTimeMillis()));
}
return element;
}
/**
* Find Element
* @param by
* @return
*/
private static boolean isElementFound(By by) {
boolean isExists = false;
//driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
try {
//System.out.println("\tStart Find Element : " + by.toString());
driver.findElement(by);
isExists = true;
} catch (NoSuchElementException e) {
//System.out.println("\tElement not found : " + by.toString());
e.printStackTrace();
}
// System.out.println("\tElement found Status : " + isExists);
return isExists;
}
Pause Video method call time : 2018-09-11 10:22:47.195
Play/ Pause video process started : 2018-09-11 10:22:47.195
Element visibility status: true Timestampe: 2018-09-11 10:22:56.509
Processing time in seconds : 19
Play / Pause video process completed : 2018-09-11 10:23:06.775
What is wrong here?
Please help me.
Thanks,
Deepak