0

I wrote a test program with selenium 2, which works great on firefox.

But when I try it with IE9, it doesn't find the elements.

for example:

WebElement sh = driver.findElement(By.id("sh"));
sh.click();

works O.K in Firefox, but not in IE9.

I read the next discussion, but it doesn't help me (I try all the suggestions) - It doesn't even find the elements, so I am not sure that this is the same problem.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Adan Vem
  • 3
  • 1
  • 4
  • are you only trying to locate your element by an id? Sometimes looking up by id fails, try using the other locator possibilities (css, xpath, class, etc.). That's the best I can tell you without your html – Greg Aug 15 '12 at 21:57
  • The IE driver for Selenium is notoriously flaky at the best of times. Are you using the latest release? – isNaN1247 Dec 18 '12 at 08:00

3 Answers3

0

Q: My XPath finds elements in one browser, but not in others. Why is this? A: The short answer is that each supported browser handles XPath slightly differently, and you're probably running into one of these differences. The long answer is on the XpathInWebDriver page.

http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_My_XPath_finds_elements_in_one_browser,_but_not_in_others._Wh

Kenn
  • 2,379
  • 2
  • 29
  • 38
0

I'm having the same problem, the test works in FF but not in IE or Chrome. The only solution I found so far is to use the JavascriptExecutor.

((JavascriptExecutor) webDriver).executeScript("arguments[0].click();", yourWebElement);

Hope you find this helpful.

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Carlos
  • 160
  • 5
0

It needs to set same Security level in all zones. To do that follow the steps below:

Open IE

Go to Tools -> Internet Options -> Security

Set all zones (Internet, Local intranet, Trusted sites, Restricted sites) to the same protected mode, enabled or disabled should not matter.

Finally, set Zoom level to 100% by right clicking on the gear located at the top right corner and enabling the status-bar. Default zoom level is now displayed at the lower right.

Ramanujam Allam
  • 1,300
  • 12
  • 11