I created the code:
new WebDriverWait(driver,100).until(
new ExpectedCondition<Boolean>(){
@Override
public Boolean apply(WebDriver driver){
if(driver.findElement(byLogin).isDisplayed()){
System.out.println("test1");
return true;
}
else if(driver.findElement(byConc).isEnabled()){
System.out.println("test1");
driver.findElement(byShop).click();
return true;
}
return false;
}
}
);
Code after "else if" never executes. How could I make the correct ExpectedCondition having both conditions above?
You cannot have return in both if.else if blocks if need to satisfy both conditions. Instead have another boolean variable and return that can be overwritten from both code blocks.
new WebDriverWait(driver,100).until(
new ExpectedCondition<Boolean>(){
boolean ind = false;
@Override
public Boolean apply(WebDriver driver){
if(driver.findElement(byLogin).isDisplayed()){
System.out.println("test1");
ind = true;
}
else if(driver.findElement(byConc).isEnabled()){
System.out.println("test1");
driver.findElement(byShop).click();
ind = true;
}
else{
ind = false;
}
return ind;
}
}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With