Reputation: 928
I am using Selenium WebDriver and run into an issue.
In the UI, elements are seen by the WebDriver but couldn't perform any actions such as click, type, select etc. Elements are found by the selenium and returned as instance of webelement. I can get, getText(),isEnabled() etc, but wont perform any actions. There is no exceptions. It just hangs.
I don't understand this behavior. If it is seen by the WebDriver, it should click. I have tried using actions. That too shows the same behavior.
How to debug this issue? Any ideas?
Upvotes: 10
Views: 22108
Reputation: 18980
If you are using Nunit, and the C# client drivers, you can attach Visual Studio to your nunit-agent.exe process by going to Tools > Attach to Process > choose "nunit-agent.exe" > Attach.
You can do the same when using JUnit, and the Java client drivers, by attaching to the nunit-agent.exe process in Eclipse.
===========
To answer your other questions...
1.) You may need to turn native events on for your driver in order to see JavaScript events.
2.) I also found some software bugs with WebDriver for Getting/Setting values. Try these for grabbing the InnerHtml (aka getText) that you were explaining in your question. This is .NET 4.0 code.. so you may need to modify it appropriately. These are in my Element class, hence the prefix of "Element" on the nested element calls.
public static int GetInnerHtmlByXPathTypeInt(IWebDriver driver, string xpath)
{
return int.Parse(Element.GetInnerHtmlByXpath(driver, xpath));
}
public static double GetInnerHtmlWithoutDollarSignByXPath(IWebDriver driver, string xpath)
{
return double.Parse(Element.GetInnerHtmlByXpath(driver, xpath).Replace("$", string.Empty));
}
public static string GetValueByXPath(IWebDriver driver, string xpath)
{
return driver.FindElement(By.XPath(xpath)).GetAttribute("value");
}
public static string GetInnerHtmlByXpath(IWebDriver driver, string xpath)
{
return driver.FindElement(By.XPath(xpath)).Text;
}
Upvotes: 0
Reputation: 14738
Little reminder: WebDriver can find for elements on page which are "hidden" by CSS.
These items are found, but are not click-able (or any other action).
Try to call method isDisplayed();
Upvotes: 4
Reputation: 928
Only way to debug the code is to write wrapper around WebDriverEventListener and listen to the logs. Other wise, it is not possible.
Upvotes: 2