Element click not functioning properly using selenium in IE 10

Wanderer picture Wanderer · Jul 18, 2014 · Viewed 23k times · Source

I am trying to automate a website using selenium in IE 10. The site opens fine however when I want to click on a element(button) it finds the element and clicks on it as well however the elements state(button name changing) which needs to be changed doesn't change.

Here is my code.

   File file = new File("D:/IEDriverServer.exe");
   System.setProperty("webdriver.ie.driver", file.getAbsolutePath() );

   DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
   capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
   true); 

   WebDriver driver = new InternetExplorerDriver(capabilities);
   driver.get("http://www.midomi.com");
   driver.findElement(By.id("searchMovielanding")).click();

I tried on two machines. On one machine the code ran properly and on another the dont see the click event changing the element state. I checked for the element on the webpage and found it however dont know why it is not clicking it properly on one machine.

  if(driver.findElements(By.id("searchMovielanding")).size() != 0) {
 System.out.println("Element Found");
 }

Any help to resolve this appreciated.

Answer

Purus picture Purus · Jul 18, 2014

Try the below.

driver.findElement(By.id("searchMovielanding")).sendKeys(KEYS.ENTER);

In IE, some times click does not work.