When using the IE driver with IE9, occasionally the Click method will only select a button, it wont do the action of the Click(). Note this only happens occasionally, so i d
I have refactored my solution based on referencing Selenium WebDriver 2.15.0 in my project and using a Selenium WebDriver Server 2.16.0 and I have made the following observations:
FirefoxDriverRemoteWebDriver for the DesiredCapabilities.FirefoxRemoteWebDriver for the DesiredCapabilities.HtmlUnit and DesiredCapabilities.HtmlUnitWithJavaScriptInternetExplorerDriver and the RemoteWebDriver with DesiredCapabilities.InternetExplorer (really the same thing) are still giving me inconsistent results that I am finding difficult to nail down.My solution to the first three points has been to create my own classes that extend RemoteWebDriver and RemoteWebElement so that I can hide my custom behaviour from the test code that continues to reference IRemoteWebDriver and IWebElement.
I have below my current "tweaks", but if you go with these custom classes you will be able tweak your driver and web element behaviour to your heart's content without having to change your test code.
public class MyRemoteWebDriver : RemoteWebDriver
{
//Constructors...
protected override RemoteWebElement CreateElement(string elementId)
{
return new MyWebElement(this, elementId);
}
}
public class MyWebElement : RemoteWebElement, IWebElement
{
//Constructor...
void IWebElement.Click()
{
if (Settings.Default.WebDriver.StartsWith("HtmlUnit"))
{
Click();
return;
}
if (TagName == "a")
{
SendKeys("\n");
Thread.Sleep(100);
return;
}
if (TagName == "input")
{
switch (GetAttribute("type"))
{
case "submit":
case "image":
Submit();
return;
case "checkbox":
case "radio":
//Send the 'spacebar' keystroke
SendKeys(" ");
return;
}
}
//If no special conditions are detected, just run the normal click
Click();
}
}