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
None of the above solutions worked for me. This did the trick tho:
element.sendKeys(org.openqa.selenium.Keys.CONTROL);
element.click();
element << org.openqa.selenium.Keys.CONTROL
element.click()
Or, if you're using Geb, there's an even better solution that's completely unobtrusive:
(tested with IE7 and Geb 0.7.0)
abstract class BaseSpec extends geb.spock.GebSpec
{
static
{
def oldClick = geb.navigator.NonEmptyNavigator.metaClass.getMetaMethod("click")
def metaclass = new geb.navigator.AttributeAccessingMetaClass(new ExpandoMetaClass(geb.navigator.NonEmptyNavigator))
// Wrap the original click method
metaclass.click = {->
delegate << org.openqa.selenium.Keys.CONTROL
oldClick.invoke(delegate)
}
metaclass.initialize()
geb.navigator.NonEmptyNavigator.metaClass = metaclass
}
}
class ClickSpec extends BaseSpec
{
def "verify click"()
{
given:
to HomePage
expect:
waitFor { at HomePage }
when:
dialog.dismiss()
// Call the wrapped .click() method normally
$('#someLink').click()
then:
waitFor { at SomePage }
}
}
class HomePage extends geb.Page
{
static url = "index.html"
static at = { title == "Home - Example.com" }
static content = {
dialog { module DialogModule }
}
}
class SomePage extends geb.Page { ... }
class DialogModule extends geb.Module { def dismiss() { ... } }
In my case, clicking in IE7 appeared to fail whenever it was preceded by the closing of an animated modal overlay (we're using jQuery Tools Overlay Modal Dialog). The Geb method above solved this problem.