When i run this code i am receiving an error as "Object reference not set to instance of object " its able to click on the first element "Services" but unable to print the text or the a href link. a href link text is "Services"
public void TestSetUp()
{
// the same way we can setup webDriver to use other browsers
driver = new FirefoxDriver();
// set the timeout after page load to 30seconds
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
}
public void TestMethod1()
{
driver.Navigate().GoToUrl("http://www.prokarma.com/");
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 20));
IWebElement hover1 = driver.FindElement(By.XPath ( "//*[@id='oe_menu']" ));
IList<IWebElement> subelements = hover1.FindElements(By.TagName("li"));
System.Console.WriteLine("Number of elements under li tag are :-->" + subelements.Count);
for (int i = 0; i < subelements.Count; i++)
{
subelements[i].Click();
string mesage = subelements[i].GetAttribute("a href").ToString();
Console.WriteLine("Value from textbox is: " + mesage);
}
}
[TestFixtureTearDown]
public void FixtureTearDown()
{
driver.Quit();
}
}
}