How to check if an element is visible with WebDriver

后端 未结 11 1522
臣服心动
臣服心动 2020-12-04 13:14

With WebDriver from Selenium 2.0a2 I am having trouble checking if an element is visible.

WebDriver.findElement returns a WebElement<

11条回答
  •  春和景丽
    2020-12-04 13:53

        try{
            if( driver.findElement(By.xpath("//div***")).isDisplayed()){
              System.out.println("Element is Visible");
            }
    }
    catch(NoSuchElementException e){
       else{
         System.out.println("Element is InVisible");
            }
    }
    

提交回复
热议问题