Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ExplicitWaitClass.java #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

testing-ninja
Copy link

Changed @BeforeMethod to @BeforeTest and @AfterMethod to @AfterTest annotations in the Selenium TestNG test suite to ensure proper setup and teardown of the WebDriver instance.

The reason behind this change is due to TestNG annotations behavior. In TestNG, @BeforeMethod and @AfterMethod are executed before and after each @test method, respectively. As a result, the WebDriver instance was not being shared between the test methods as expected, leading to a 'null' reference error when trying to close the browser in the @AfterMethod.

By using @BeforeTest and @AfterTest annotations, the WebDriver setup is now performed before the entire test suite starts (@BeforeTest) and the teardown is done after all the tests have run (@AfterTest). This ensures the WebDriver instance is initialized once at the beginning of the test suite and closed after all the tests have completed, preventing the 'null' reference issue and ensuring a smoother execution of the test suite.

This adjustment ensures a more reliable and consistent handling of the WebDriver instance throughout the entire test suite, enhancing the stability and reliability of the test automation setup.

Changed @BeforeMethod to @BeforeTest and @AfterMethod to @AfterTest annotations in the Selenium TestNG test suite to ensure proper setup and teardown of the WebDriver instance.

The reason behind this change is due to TestNG annotations behavior. In TestNG, @BeforeMethod and @AfterMethod are executed before and after each @test method, respectively. As a result, the WebDriver instance was not being shared between the test methods as expected, leading to a 'null' reference error when trying to close the browser in the @AfterMethod.

By using @BeforeTest and @AfterTest annotations, the WebDriver setup is now performed before the entire test suite starts (@BeforeTest) and the teardown is done after all the tests have run (@AfterTest). This ensures the WebDriver instance is initialized once at the beginning of the test suite and closed after all the tests have completed, preventing the 'null' reference issue and ensuring a smoother execution of the test suite.

This adjustment ensures a more reliable and consistent handling of the WebDriver instance throughout the entire test suite, enhancing the stability and reliability of the test automation setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant