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
Absolutely none of the other things worked for me. Some InternetExplorerDriver click()s were working for me, some weren't. Then I discovered I had missed one line in the documentation: the browser's zoom level must be set to 100%.
I'm sure all of the other answers refer to cases where the zoom level is at 100% already, but it did fix my case. So do check that first.
PHPUnit + facebook / php-webdriver sometimes the function click() doesn't check checkbox element.
my solution is:
$Element = $WebDriver->findElement(
WebDriverBy::id('checkbox_id')
);
if(false === $Element->isSelected())
{
$Element->sendKeys(WebDriverKeys::SPACE);
}
I used, as workaround, SendKeys with an empty string before each Click:
element.SendKeys("");
element.Click();
I find the IE driver buggy and the same version of my code behaves differently on different machines with the same version of IE.
To get consistently before each action I do the following.
driver.SwitchTo().Window(driver.CurrentWindowHandle);//Force Focus
For me this makes the IE driver behave more as expected.
Got the same problem, click does not work with my IE. I found a workaround where I do a Driver.FindElement(By.Name("...")).sendKeys("\n") to perform the click (basically I just press enter on the button). Not very clean but it works until the problem is fixed!
I resolved problem whith .click() next way. I used JS and executeScript(JS, WebElement el) instead of .click().
Example:
protected void clickForIE(WebElement element){
((JavascriptExecutor)wd).executeScript("var tmp = arguments[0];
tmp.click()", element);
}
But after using this method we should wait while page loading. And that's why I used next method:
protected synchronized void pageWaitLoad() {
String str = null;
try {
str = (String)((JavascriptExecutor)wd).executeScript("return document.readyState");
}
catch (Exception e) {
// it's need when JS isn't worked
pageWaitLoad();
return;
}
System.out.println("ttt " + str);
while(!str.equals("complete")){
try {
Thread.currentThread().sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
str = (String)((JavascriptExecutor)wd).executeScript("return document.readyState");
}
}
You must call pageWaitLoad() every time after clickForIE().