WebDriver provides implicit wait and explicit wait. In explicit wait also, we can use predefined wait conditions and we can create our own conditions using anonymous class and implementing apply method.
So, now textToBePresentInElement(locator,String) and textToBePresentInElementValue(locator,String) are predefined by ExpectedCondition which is used to set explicit wait.
So, we can use :
WebDriverWait wait=new WebDriverWait(driver,10);
//create WebDriverWait instance with parameters passed - 1. WebDriver instance, 2. maximum wait in case ExpectedCondition fails.
wait.until(ExpectedCondition.textToBePresentInElement(By,"Looking4TextOnElement");//This verifies if text is present on element By.
wait.until(ExpectedCondition.textToBePresentInElementValue(By,"Looking4TextOnValueAttribute");//This verifies if text is present in value attribute of element By.
So, now textToBePresentInElement(locator,String) and textToBePresentInElementValue(locator,String) are predefined by ExpectedCondition which is used to set explicit wait.
So, we can use :
WebDriverWait wait=new WebDriverWait(driver,10);
//create WebDriverWait instance with parameters passed - 1. WebDriver instance, 2. maximum wait in case ExpectedCondition fails.
wait.until(ExpectedCondition.textToBePresentInElement(By,"Looking4TextOnElement");//This verifies if text is present on element By.
wait.until(ExpectedCondition.textToBePresentInElementValue(By,"Looking4TextOnValueAttribute");//This verifies if text is present in value attribute of element By.
can u please give a real example
ReplyDeleteferzi
ReplyDeleteHi Debasish,
ReplyDeletewhat is the difference between textToBePresentInElement and textToBePresentInElementLocated.
Thanks,
Pramod Kajla