Skip to main content
deleted 16 characters in body
Source Link
Muzzamil
  • 211
  • 1
  • 5

To resolved this issue ensuring that all PageObjects, were properly re-initialized before each test.

It ensures that the ElementFinder properties are using the current browser session.

Below is code snippet to initialise a page object before each test.

beforeEach(() => {
    //Ensure that we initialize the page object before every test as we otherwise hold references to old browser instances, which fails when restartBrowserBetweenTests is true.
    loginPagestageObj = new PageObjects.Loginstage1();
});

First test always passed, but all subsequent tests failed because we used previously-initialized objects with elements that were acquired for the first browser instance, which then got intentionally discarded after the first test completed. In other words, make sure you re-acquire each element you need for your test.

To resolved this issue ensuring that all PageObjects, were properly re-initialized before each test.

It ensures that the ElementFinder properties are using the current browser session.

Below is code snippet to initialise a page object before each test.

beforeEach(() => {
    //Ensure that we initialize the page object before every test as we otherwise hold references to old browser instances, which fails when restartBrowserBetweenTests is true.
    loginPage = new PageObjects.Login();
});

First test always passed, but all subsequent tests failed because we used previously-initialized objects with elements that were acquired for the first browser instance, which then got intentionally discarded after the first test completed. In other words, make sure you re-acquire each element you need for your test.

To resolved this issue ensuring that all PageObjects, were properly re-initialized before each test.

It ensures that the ElementFinder properties are using the current browser session.

Below is code snippet to initialise a page object before each test.

beforeEach(() => {
    //Ensure that we initialize the page object before every test as we otherwise hold references to old browser instances, which fails when restartBrowserBetweenTests is true.
    stageObj = stage1();
});

First test always passed, but all subsequent tests failed because we used previously-initialized objects with elements that were acquired for the first browser instance, which then got intentionally discarded after the first test completed. In other words, make sure you re-acquire each element you need for your test.

Source Link
Muzzamil
  • 211
  • 1
  • 5

To resolved this issue ensuring that all PageObjects, were properly re-initialized before each test.

It ensures that the ElementFinder properties are using the current browser session.

Below is code snippet to initialise a page object before each test.

beforeEach(() => {
    //Ensure that we initialize the page object before every test as we otherwise hold references to old browser instances, which fails when restartBrowserBetweenTests is true.
    loginPage = new PageObjects.Login();
});

First test always passed, but all subsequent tests failed because we used previously-initialized objects with elements that were acquired for the first browser instance, which then got intentionally discarded after the first test completed. In other words, make sure you re-acquire each element you need for your test.