0

This question is regarding Selenium WebDriver running on Internet Explorer.

On Internet Explorer, the vary basic selenium method that is click() does not works most the of the time. This is my code:

System.setProperty("webdriver.ie.driver", "<path_to_iedriverserver>");
DesiredCapabilities d = DesiredCapabilities.internetExplorer();
//d.setCapability("nativeEvents", false);
webdriver = new InternetExplorerDriver(d);
webdriver.get("http://google.co.uk");
webdriver.findElement(By.linkText("Images")).click();
webdriver.findElement(By.linkText("Search")).click();

This script usually clicks "Images" link successfully, but in some cases it fails to click "Search" afterwards. It is not a synchronization issue, the same issue happens when there is a, say, Thread. Sleep() between the clicks. Moreover, if script is stopped at the breakpoint after this code and user tries to click links manually, it does not work either, but URL's keep flashing in the Internet Explorer status bar as if some click event was not completely handled. When IEDriverServer.exe process is killed, this browser window becomes responsive again.

This is my system information:

Selenium version: 4.42.2
OS: Windows 7
Browser: IE 9, IEDriverServer_Win32_2.42.0,
Tim Visée
  • 2,988
  • 4
  • 45
  • 55
Hariprasad
  • 15
  • 4
  • On google.co.uk, after clicking the "Images" link, there is no "Search" link on the next page! – SiKing Jul 25 '14 at 17:17

2 Answers2

0

In IE, most of the times click() does not work. I have faced this several times and I take different approach which works in all browsers.

Use sendKeys(Enter) instead of click() and that should work.

webdriver.findElement(By.linkText("Images")).sendKeys(KEYS.ENTER));
frianH
  • 7,295
  • 6
  • 20
  • 45
Purus
  • 5,701
  • 9
  • 50
  • 89
0

You can also consider invoking java script click on the element.

WebElement element = driver.findElement(By.id("value"));
JavascriptExecutor jse= (JavascriptExecutor)driver;
jse.executeScript("arguments[0].click();", element);
Lukasz
  • 368
  • 4
  • 9