简体   繁体   English

在这种情况下使用Thread.sleep是否可以接受-Webdriver

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

I am not sure if I am misusing Thread.sleep 我不确定是否滥用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()! 我在我的框架中有一些测试参数化的测试,每当我拆掉测试时(调用driver.quit())...然后针对下一个测试重新启动,就会收到此错误-会话ID为空...调用quit()后运行测试!

Hence I introduced Thread.sleep() before re-initiating the tests and this solved the problem.But Am I misusing the Sleep here? 因此,我在重新启动测试之前引入了Thread.sleep(),这解决了问题。但是我在这里滥用Sleep吗? 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. 调用driver.quit()关闭浏览器并结束Selenium驱动程序本身,这就是为什么您下次要访问驱动程序时会收到异常。

We used JUnit for our Selenium tests and used the @beforeClass and @afterClass parts to setup and shutdown Selenium. 我们将JUnit用于Selenium测试,并使用@beforeClass@afterClass部分来设置和关闭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. @beforeClass也是我们打开页面并登录并进行初始登录成功验证声明的部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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