Here is the Selenium RC code for selenium.GetAttribute in Webdriver. This code is in Visual Studio C#
public string GetAttribute(string xpath, string attribut)
{
string value = "";
if (IsElementPresent(xpath))
{
value = driver.FindElement(By.XPath(xpath)).GetAttribute(attribut);
}
return value;
}
Here is the Selenium RC code for selenium.Select in Webdriver. This code is in Visual Studio C#
public void Select(string xpath, string value)
{
driver.FindElement(By.XPath(xpath+"/option[.='"+value+"']")).Click();
}
Here is the Selenium RC code for selenium.Open in Webdriver. This code is in Visual Studio C#
public void Open(string URL)
{
driver.Navigate().GoToUrl(URL);
}
Here is an example to verify the canonical tag on a web page using Selenium GetLocation. The selenium script is written in C#
public int CheckCanonicalTag()
{
int resultcount = 0;
string URL = selenium.GetLocation();
if (selenium.IsElementPresent("//link[@rel='canonical' and @href='" + System.Web.HttpUtility.UrlDecode(URL) + "']"))
{
Console.WriteLine( "Canonical tags is present on the page :" + URL);
}
else
{
Console.WriteLine( "Canonical tags is not present on the page :" + URL);
resultcount++;
}
return resultcount;
}
On an Ajax web application or Ajax feature on web page small sections of the page will update and often the entire webpage will not load. It’s necessary to wait until this ajax process is completed before interacting with sections of the page where content or controls are yet to be rendered.
Here is the html code input id=”qu” and the text in the text input box is Selenium Wiki.
To validate the text from a text box using Selenium RC you will have to use the Selenium command selenium.getValue(). This will get the value in the location input id=”qu”.
selenium.getValue(“//input[@id='qu']“)