简体   繁体   中英

Is it acceptable to use Thread.sleep in this case - Webdriver

I am not sure if I am misusing Thread.sleep

I have some tests within my framework which are parametrized and for every test when i tear down(call driver.quit())...and then re initiate for the next test am getting this Error --Session ID is null...Running tests after calling quit()!

Hence I introduced Thread.sleep() before re-initiating the tests and this solved the problem.But Am I misusing the Sleep here? Your answers would be helpful!

thanks

The call to driver.quit() closes the browser and end the Selenium driver itself, that's why you get the exception the next time you want to access the driver.

We used JUnit for our Selenium tests and used the @beforeClass and @afterClass parts to setup and shutdown Selenium. So every test class used it's own browser session, and all tests within that class shared the same one. @beforeClass was also the part where we opend the page and logged in and did an initial login-successful-validation assertion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM