Best practice to wait for a change with Selenium Webdriver?

前端 未结 5 2324
情话喂你
情话喂你 2021-02-13 02:08

After a click event I need to wait for an elements attribute to change before proceeding further (click event causes certain elements to move out of focus and certain others get

5条回答
  •  隐瞒了意图╮
    2021-02-13 02:59

    You could use Thread.sleep like people have implemented here..You can use their implementations to relate to your problem.

        public void waitFor(Webdriver driver,,WebElement welElem, String attributeValue){
        int timeout=0;
        while(true){
            if(driver.webElem.getAttribute(attribute)!=null){
            break;
            }
            if(timeout>=10){
            break;
            }
            Thread.sleep(100);
            timeout++;
        }
    
    }
    

    I think you could implement something like this. I have not checked it but you get the idea.

提交回复
热议问题