Selenium IDE - How to check that an element (CSS) is visible?

Example 1: Verifying that the Twitter modal firewall has opened.

The modal already exists on the page, but is hidden from CSS until the modal is open. So how can I check if it is modally open?

Example 2. Checking the display of a user error message.

The error message always exists, but is hidden from CSS until it is needed. How to check that a message is visible?

+5
source share
3 answers

verifyVisible. css, , ​​ . true, false . . , css.

+10

1:

, Presence Visibility - .

2:

Visibility .

:

if(driver.findElements(By.xpath("value")).size() != 0){
System.out.println("Element is Present");
}else{
System.out.println("Element is Absent");
}

if(driver.findElement(By.xpath("value"))!= null){
 System.out.println("Element is Present");
}else{
System.out.println("Element is Absent");
}

Visible:

if( driver.findElement(By.cssSelector("a > font")).isDisplayed()){
System.out.println("Element is Visible");
}else{
System.out.println("Element is InVisible");
}
+1

.

, true, dom, false.

isElementPresent(WebDriver driver,By by)  
 {  
    driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);  
    try  
    {  
       driver.findElement(by);  
       return true;  
    }  
    catch(Exception e)  
    {  
       return false;  
    }  
    finally  
    {  
       driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);  
     }  
 } 

.

0

All Articles