Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workarounds for Selenium not clicking button with InternetExplorerDriver

I've got a button on a webpage that Webdriver will not click when I'm running via IE - I've tried the below workarounds but no luck -

Clicking via Javascript:

((JavascriptExecutor) driver).executeScript("$(arguments[0]).click()", webElement)

Using SendKeys:

webElement.SendKeys(keys.Enter)

Using the Action Builder

Actions test = new Actions(driver);
        test.moveToElement(webElement);
        test.clickAndHold();
        test.release();
        test.build();
        test.perform();

Making sure the window is the active one, then clicking on the parent object, then the object itself

Problem is, none of them work. I've checked in Firefox and Chrome and the script runs fine. I've confirmed that the element is being found when using IE. Are there any other workarounds I can try?

like image 663
Dave Avatar asked Jan 16 '12 11:01

Dave


1 Answers

Seems you are tyring to use JQuery style click... normal javascript style click should work.

Try this:

((JavascriptExecutor) driver).executeScript("arguments[0].click();", webElement)

I always found successful with the following for clicking an element in IE.

  1. If is a checkbox/radio: webElement.click();
  2. Clickable input element: webElement.sendKeys("\n");
  3. For other elements, use the above said JS style click.
like image 101
KrishPrabakar Avatar answered Oct 24 '22 12:10

KrishPrabakar