Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

513
Visualizações
Selenium Wait for anyone of Element to visible

While Clicking a particular button - my test site will open modal window.

But the modal window opens are differ, either it opened with modal window 1 or modal window 2

Both are having different title, different options and different locators. Now I should have to wait until the modal window open Either 1 or 2.

Is it possible to wait until either one modal window (WebElement) is visible?

I have searched in WebDriverWait methods, but all methods are to wait until a particular WebElement to visible or clickable.

I can't find a better method to wait until either one is visible.

Could you suggests any one method to solve this situation?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can use or expected conditions for that

WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.or(
    ExpectedConditions.visibilityOfElementLocated(By.id("id1")),
    ExpectedConditions.visibilityOfElementLocated(By.id("id2"))
));

Or use cssSelector or ,

wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#id1, #id2"));
over 4 years ago · Santiago Trujillo Relatório

0

To induce WebDriverWait until either one modal window WebElement is visible you can use the or() clause as follows:

new WebDriverWait(driver, 10).until(ExpectedConditions.or(
    ExpectedConditions.visibilityOfElementLocated(By.name("name_modalA_element")),
    ExpectedConditions.visibilityOfElementLocated(By.xpath("xpath_modalB_element"))
));

With cssSelector you can seperate the elements using the comma character i.e. , as follows:

new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("css_modalA_element, css_modalB_element"));

References

You can find a couple of relevant detailed discussions in:

  • How to extract dynamic text from multiple child nodes within the html through getText()
  • Logic Operators in WebDriverWait Expected Conditions
  • How to wait for either of the two elements in the page using selenium xpath
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda