driver.findElement

Creating getText function for Selenium 2 in C Sharp 

As most of you know there is no getText() function in Selenium 2 C#; I have created a function that you can use to get the text associated with a element/xpath.

public String getText(String xpath)
{
String x = driver.FindElement(By.XPath(xpath)).Text;
return x;
}

Here is how I have used the getText() function in my test script:
Console.WriteLine(getText(“//div[@id='fll']/a[1]“));
Printing the text assoicated with the xpath “//div[@id='fll']/a[1]“

Using getAttribute in Selenium 2 Webdriver 

In this example I will tell you how you can use selenium command getAttribute in Selenium 2 Webdriver. I had to use this as selenium.getAttribute was not working on Webdriver when I was using HtmlUnitDriver. It was working when I was using FirefoxDriver. I had to convert the selenium.getAttribute to make it work on both HtmlUnitDriver and FirefoxDriver.

More…

Using getText in Selenium 2 Webdriver 

In this example I will tell you how you can use selenium command getText in Selenium 2 Webdriver. I had to use this as selenium.getText() was not working on Webdriver when I was using HtmlUnitDriver. It was working when I was using FirefoxDriver. I had to convert the selenium.getText() to make it work on both HtmlUnitDriver and FirefoxDriver.

More…