How to use Verifyelementpresent in Selenium 

You can use selenium.IsElementPresent(“element”) to see if a particular element is present on the web page. This is a very powerful function in selenium as you can use it with a if condition.
In this example I am first checking if there is an element //td[@class='Selenium'] on the web page. If yes then I click the element //td[@class='Selenium'] and continue checking the other conditions.

if (selenium.IsElementPresent("//td[@class='Selenium']"))
{
selenium.Click("//td[@class='Selenium']");
selenium.WaitForPageToLoad("30000");
try
{
Assert.IsTrue(selenium.IsElementPresent("//td[@class='Selenium1']"));
}
catch (AssertionException)
{
writefail("Selenium RC is Present");
}
}
else
{
writefail("Selenium RC link does not exist");
}

Submitted by Pavandeep Puddupakkam


Author: Pavandeep Puddupakkam on July 21, 2010
Category: Selenium RC
Tags: , ,
Google Webdriver Forum -The Online Community for Google Webdriver and Selenium RC Users and Professionals
1 response to “How to use Verifyelementpresent in Selenium”
  1. jm says:

    What references are you using here?

Leave a Reply

Last articles