0

I wonder if there is a way to use selenium expected conditions where there are two code scenarios for two expected conditions and only one time period to wait (same timeout counter exception); I mean:

  • if expected condition 1 ---> code scenario 1;
  • if expected condition 2 ---> code scenario 2;
  • else if timeout(20) ---> Exception code scenario.

My code:

try {
    new WebDriverWait(driver, Duration.ofSeconds(30)).until(ExpectedConditions.elementToBeClickable(By.name("AAA")));
    then my scenario 1 code for execution;
catch(TimeoutException e) {
    System.out.println("Time out!");
}
try {
    new WebDriverWait(driver, Duration.ofSeconds(30)).until(ExpectedConditions.elementToBeClickable(By.name("BBB")));
    then my scenario 2 code for execution;
catch(TimeoutException e) {
    System.out.println(Time out!");
}
Ahmed
  • 1
  • 1
  • The conditions have to be checked at the same time or first check one and then another? – Alexey R. Aug 06 '22 at 09:46
  • The conditions have to be checked at the same time. Either 1st condition is fullfilled or the 2nd, if not, then the code has to show timeout exception. – Ahmed Aug 07 '22 at 01:18

0 Answers0