Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda