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

149
Views
No puedo hacer clic en el botón "Estoy de acuerdo" en Selenium con NodeJS

Intento escribir una prueba automática en Selenium con NodeJS y tengo un pequeño problema.

En primer lugar, mi código:

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

Cada vez que inicio mi aplicación con "índice de nodo", se abre una nueva aplicación de Chrome/Firefox y me pregunta si estoy de acuerdo con las cookies. Intenté ir a la configuración o conectar mi cuenta y permitir las cookies en cualquier momento, pero si vuelvo a iniciar mi aplicación, mi configuración desaparece.

Creo que la solución es hacer clic manualmente en el botón "Estoy de acuerdo" con mi código, pero no sé cómo hacerlo. ¿Puede alguien ayudarme por favor?

¿Cómo debo escribir el código para poder hacer clic en el botón de acuerdo o qué más debo probar?

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

0

Para hacer clic en I agree utilice el siguiente xpath para identificar el elemento

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

Tu código será

 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!