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

214
Views
Selenium JavaScript Try Catch block no funciona como se esperaba

Estoy tratando de arrojar un error en la consola si se hace clic en el primer enlace de los resultados de búsqueda de Bing. Mi código funciona bien hasta que se abre el primer enlace, pero no veo ningún mensaje en la consola que indique que se hizo clic con éxito en el primer enlace y cuando realizo un cambio de código intencional para detectar el error, la captura no genera un error. Estoy usando node.js, selenium y edge webdriver. Por favor ayúdame a arreglar esto.

 const { Builder, By } = require('selenium-webdriver'); async function launchEdgeBing() { let driver = await new Builder().forBrowser('MicrosoftEdge').build(); await driver.get('https://bing.com'); await driver.manage().window().maximize(); const element = await driver.findElement(By.id('sb_form_q')); await driver.sleep(5000); await element.sendKeys('latest news'); await element.submit(); await driver.sleep(5000); try { const clickFirstResult = await driver.findElement( By.className('b_title') ); clickFirstResult.click(); await driver.sleep(5000); var title = await driver.getTitle(); console.log('Title is:', title); } catch (e) { if (e == null) { console.log('First link opened successfully'); } else { console.log('Error is:', e); } } finally { await driver.quit(); } } launchEdgeBing();
about 4 years ago · Juan Pablo Isaza
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!