Wednesday, 29 May 2019

webdriverIO - Unhandled promise rejection: NoSuchSessionError: invalid session id

I'm learning UI testing with Jasmine & WebdriverIO. I use it with NodeJS. I have the next test code:

const projectsPage = require('../../lib/pages/projects.page');
const by = require('selenium-webdriver').By;

describe('Projects page', () => {
  it('Search google', async() => {
    await projectsPage.navigateTo();
    driver.getTitle().then(function(title) {
      expect(title).toBe('Google');
    });
    driver.findElement(by.name('q')).sendKeys('test');
  })
});

When I run it, I receive the error:

Unhandled promise rejection: NoSuchSessionError: invalid session id
      (Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.5 x86_64)

But the code below performs successfully:

describe('Projects page', () => {
  it('Search google', async() => {
    await projectsPage.navigateTo();
    driver.getTitle().then(function(title) {
      expect(title).toBe('Google');
    });
    driver.findElement(by.name('q'))
  })
});

Where I was wrong?



from webdriverIO - Unhandled promise rejection: NoSuchSessionError: invalid session id

No comments:

Post a Comment