Reputation: 81
I can use Thread.sleep();
but my boss doesn't want me to do that so I used explicit wait
webDriverWait.until(ExpectedConditions.presenceOfElementLocated(By.xPath("")));
but it is not working as well because the xpath
is not present as the data(Text) that appears in sometime.
Upvotes: 0
Views: 815
Reputation: 2922
textToBePresentInElementLocated
method. Let's see below example,HTML#1:
<input class="google"> Text </input>
Wait till text presents if you know the expected text
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//input[@class='google']"), "Text"));
HTML#2:
<input class="google" value="Text" >
Wait till attribute have some value
WebElement element = driver.findElement(By.xpath("//input[@class='google']"));
wait.until(ExpectedConditions.attributeToBeNotEmpty(element, "value"));
How to read properties file?
https://stackoverflow.com/a/69236087/7731623
Dynamic xPath:
/** Code to read properties file **/
String inputData = readProperties.getProperty("Data").trim();
driver.findElement(By.xpath("//input[@class='"+inputData+"']"));
wait.until(ExpectedConditions.attributeToBeNotEmpty(element, "value"));
Upvotes: 2