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

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

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 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