Best way to check that element is not present using Selenium WebDriver with java

后端 未结 9 1923
半阙折子戏
半阙折子戏 2020-12-24 02:33

Im trying the code below but it seems it does not work... Can someone show me the best way to do this?

public void verifyThatCommentDeleted(final String text         


        
9条回答
  •  时光说笑
    2020-12-24 03:03

    public boolean isDisplayed(WebElement element) {
            try {
                return element.isDisplayed();
            } catch (NoSuchElementException e) {
                return false;
            }
        }
    

    If you wan t to check that element is displayed on the page your check should be:

    if(isDisplayed(yourElement){
    ...
    }
    else{
    ...
    }
    

提交回复
热议问题