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

274
Vistas
Why do I keep getting NoSuchSessionError when running Selenium in Node.js?

When I run the script, the automated web browser does load and so does the website I wanted it to load but it shuts off instantly without doing anything else. I had looked at the docs and used the wait method in case the website I was trying to load does a lot of AJAX loading but it still doesn't seem to be working. Can anyone please explain what is going on and how I am getting this error?

Here is the JavaScript code:

const {Builder, By, until} = require('selenium-webdriver');

(async function helloSelenium() {
    let driver = await new Builder().forBrowser('safari').build();

    await driver.get('https://www.google.com/?client=safari');

    let ele = await driver.wait(until.elementLocated(By.id('gbqfbb'), 10000));
    let b = await driver.findElement(By.id('gbqfbb'));
    console.log(b.getText());

    await driver.quit();
})();

And here is the error:

user@MacBook-Pro webscraper % node webscraper.js
Promise { <pending> }
/Users/user/Documents/Web/webscraper/node_modules/selenium-webdriver/lib/error.js:522
    let err = new ctor(data.message)
              ^

NoSuchSessionError
    at Object.throwDecodedError (/Users/user/Documents/Web/webscraper/node_modules/selenium-webdriver/lib/error.js:522:15)
    at parseHttpResponse (/Users/user/Documents/Web/webscraper/node_modules/selenium-webdriver/lib/http.js:548:13)
    at Executor.execute (/Users/user/Documents/Web/webscraper/node_modules/selenium-webdriver/lib/http.js:474:28)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Driver.execute (/Users/user/Documents/Web/webscraper/node_modules/selenium-webdriver/lib/webdriver.js:735:17) {
  remoteStacktrace: ''
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to change the below

From

let ele = await driver.wait(until.elementLocated(By.id('gbqfbb'), 10000));

to

let ele = await driver.wait(until.elementLocated(By.id('gbqfbb')), 10000);

t's also important to notice that if this method throws an exception (timeout exception), so you must try-catch it too.

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