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

251
Visualizações
Click Element in Selenium Javascript not working

I am automating a website in which I want to click on the x when a subscription popup comes up The HTML for the X is

<button title="Close popup message" data-testid="email-popup-close-button" id="email-popup-close-button" class="dw-1hfj58t-CloseBtn--EmailContainer e1lwf35p0">×</button>

So to click on this I am using the below

await driver.findElement(By.id("email-popup-close-button")).click();

But it is coming up with the below error

NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"*[id="email-popup-close-button"]"}

Screenshot attached here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

It seems like the issue with locator. Give a try to below.

await driver.findElement(By.xpath("(//button[normalize-space()='×'])[1]")).click();

Or

await driver.findElement(By.xpath("//button[@title='Close popup message']")).click();

Or

WebDriverWait wait = new WebDriverWait(driver,30);
elem = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@title='Close popup message']")));
elem.click();

Import:

import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait

Let me know if this does not work.

about 4 years ago · Juan Pablo Isaza Relatório

0

Found the answer Declared this const {Builder, By, Key, until} = require("selenium-webdriver");

and used

let query = driver.wait(until.elementLocated(By.id('email-popup-close-button')));
    await query.click();
about 4 years ago · Juan Pablo Isaza 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