简体   繁体   English

Selenium Webdriver(Java)-脚本之间的时间延迟

[英]Selenium Webdriver (Java) - time delay between the scripts

I have one script (test suite) , which run other scripts. 我有一个脚本(测试套件),该脚本可以运行其他脚本。

  @RunWith(Suite.class)
    @Suite.SuiteClasses({
            Test002.class,
            Test001.class})

    public class SuiteTest1 {

    }​

I am struggling many times with time out problems to find an object on the page. 我在超时问题上苦苦挣扎很多次,无法在页面上找到对象。 Even when place Thread.sleep or WebDriverWait. 即使放置Thread.sleep或WebDriverWait。 So, is there possibility to put in my main class some delay between scripts? 因此,是否有可能在我的主类中添加脚本之间的一些延迟?

Something like with Thread.sleep(1000): Thread.sleep(1000)之类的东西:

@RunWith(Suite.class)
    @Suite.SuiteClasses({
            Test002.class,
            Thread.sleep(1000);
            Test001.class})

You can do it on test level. 您可以在测试级别上进行。 If you want to make some pauses between test runs, just use method decorated with @BeforeTest where you can place any Thread.sleep(1000) . 如果要在测试运行之间@BeforeTest停顿,只需使用@BeforeTest装饰的方法@BeforeTest在其中放置任何Thread.sleep(1000)

In case when you have to use such login in more than one test, use general parent class where you declare the same logic and then you can inherit from it. 如果必须在多个测试中使用这种登录名,请使用通用父类在其中声明相同的逻辑,然后可以从中继承。

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

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