Selenium 2 – Checking If An Element Is Displayed

In the original version of Selenium, you started the selenium server and used it to check if an element is present by calling its isElementPresent( ) method. An example:

assertTrue(selenium.isElementPresent(“pageBanner”));

In Selenium 2, you call the WebElement method isDisplayed( ) on the element itself, found using the web driver. An example:

WebElement banner = driver.findElement(By.id(“pageBanner”));

assertTrue(banner.isDisplayed( ));

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: