0

Scripts:

IWebDriver ie = new InternetExplorerDriver();
IWebDriver ff = new FirefoxDriver();
string baseURL = "http://xxxxxxxxxxxx";
ISelenium iesele = new WebDriverBackedSelenium(ie, baseURL);
ISelenium ffsele = new WebDriverBackedSelenium(ff, baseURL);

The page of baseURL has 2 frames and the upper frame is a warning page, and I want to select "Agree" then Click on "OK" to close it. Scripts of IE doesn't work, can discover the object of the checkbox and button, but "Select" and "Click" doesn't work. But under Firefox, it works, the upper frame was closed successfully. Script: IE

iesele.Start();
iesele.Open(baseURL);
iesele.SelectFrame("UpperFrame");
iesele.FindElement(By.Name("agree")).Click();
iesele.FindElement(By.CssSelector("ok")).Click();

Firefox

ffsele.Start();
ffsele.Open(baseURL);
ffsele.SelectFrame("UpperFrame");
ffsele.FindElement(By.Name("agree")).Click();
ffsele.FindElement(By.CssSelector("ok")).Click();

Does anyone know why IE cannot execute this script correctly? Should I set something of IE8 ?

thanks

David Wu
  • 711
  • 2
  • 7
  • 9

3 Answers3

0

Hmm i have searched around for your issue; maybe you also have the same issue as in this stackoverflow question:

Selenium 2.0b3 IE WebDriver, Click not firing

Here it seems the given frame needs to have focus (via a click()) before the actual click() is registered on your element.

Community
  • 1
  • 1
Mark van Straten
  • 9,287
  • 3
  • 38
  • 57
0

There are differences in the way each browser renders a page and also differences in the Selenium drivers (so it may not be possible to use exactly the same script for different browsers).

You might find this answer to a similar question useful. In particular, try selecting and clicking on a parent of the target element (such as a <div>) instead of the element itself. And also, try using MouseDown() followed by MouseUp() instead of Click().

Community
  • 1
  • 1
shamp00
  • 11,106
  • 4
  • 38
  • 81
  • I don't know whether it's the issue of the page or not, only Click/Select/Check methods works. Using Mouse/Key related method/function will result in an error: – David Wu Apr 18 '12 at 09:53
  • Error: There is no source code available for the current location. When I tried to MouseDown on the checkbox(Javascript in the html source), this error occurred. Only on IE8, not happened to Firefox. – David Wu Apr 18 '12 at 09:54
0

I have found a few times that Firefox will work on finding and interacting with an element but IE will fail at various spots. Most of the time I throw in a 'wait for element' and the IE issue is resolved. I think IE is sometimes a bit slower creating elements (or does things in a different order?) so at times the element doesn't exist when you aim to click it. This might not be your issue, but it seems to happen to me rather frequently!

edit: I also use Chrome, and often FF and Chrome work when IE fails.

Nashibukasan
  • 2,028
  • 23
  • 37