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

138
Views
Can't click "I am agree" button in Selenium with NodeJS

I try to write an automatic test in Selenium with NodeJS and I have a little problem.

First of all, my code:

const {Builder, By, Key, until} = require("selenium-webdriver");
async function example() {
    let driver = await new Builder().forBrowser('chrome').build();
    await driver.get('http://www.google.com');
    await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
    await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
  
}

example();

Every time i start my app with "node index", a new chrome/firefox app is opening and asking me if I am agree with cookies. I tried to go to settings or to connect my account and allow cookies anytime but if I start again my app, my settings are gone.

I think the solution is to click manually that "I am Agree" button with my code but I don't know how to do this. Can anybody help me, please?

How should I write the code to can click that agree button or what else I should try?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To click on I agree use the following xpath to identify the element

await driver.findElement(By.xpth('//div[text()="I agree"]')).click()

Your code will be

const {Builder, By, Key, until} = require("selenium-webdriver");
async function example() {
    let driver = await new Builder().forBrowser('chrome').build();
    await driver.get('http://www.google.com');
    await driver.findElement(By.xpth('//div[text()="I agree"]')).click();
    await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
    await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
  
}

example();
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!