Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!