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

272
Views
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 answers
Answer question

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