3

I have been writing my scripts for FF but was hoping with little work they would also run on the other browsers but it seems IE driver has button issues?

I have a simple webelement.click() on a button that does not throw an error but does not click the button. in FF its fine. I can get text, get value so I know the find statement is ok it just will not click it.

thoughts or help would be great

Just doing

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

HTML - The control has 3 buttons on it I am only interested for now with the login

<div id="_ctl0_pageheader_navcontainer">
  <div id="phwelcome">

    <br class="clear" />
  </div>
  <span id="navtext">

    <a id="_ctl0_pageheader_lnkRegister" class="logichref" 
       href="http://Register/1">Register Today</a>
    <label id="_ctl0_pageheader_lblRegisterBar" class="barhide">| </label>

    <a id="_ctl0_pageheader_customerconnection" class="logichref" 
       href="http://test.com" target="_blank">Help & Training</a>
    <label class="bar">| </label>
    <a class="logichref" href="http://test.aspx"
       onmouseover="window.status='';return(true);" 
       onmouseout="window.status='';return(false);"
       target="_blank">What's New</a> 
    <label class="bar">| </label>
    <a id="_ctl0_pageheader_login" class="lbOn loginModal" 
       href="http://test/loginlightbox.aspx">Login</a>
  </span>
</div>     
Bernhard Kircher
  • 4,132
  • 3
  • 32
  • 38
ducati1212
  • 855
  • 9
  • 18
  • 29

7 Answers7

5

Got the same problem, click does not work with my IE 8. I found a workaround where I do a element.sendKeys("\n") to perform the click (basically I just press enter on the button). Not very clean but it works until the bug is fixed!

  • 1
    Are you aware of a bug that has been filed for this in Selenium? I am searching but cannot find anything... – Randy Sep 13 '11 at 22:09
  • Your solution sound smart, but what is the equivalence if we are using ipad simulator ? – Emna Ayadi Apr 28 '16 at 17:00
5

I almost gave up on WebDriver as I couldn't get the click method on webelement to function. But for some reason I changed my IE zoom from 125% to 100% and the click worked. Not sure if this is a known bug with WebDriver but it almost made me scrap it all together until I found a solution.

Brian Elstner
  • 51
  • 1
  • 2
  • I was using @Emmanuel's solution posted here because I had the same issue. But after I set the zoom level to 100% (Mine was set to 90%!), the click worked beautifully! Thanks! – Ranhiru Jude Cooray May 21 '12 at 11:04
  • I spent a day and a half on this issue and after finding your answer discovered the zoom was set to 105% back at 100% now and it's working perfectly. Thank you. – Mike Bartlett Apr 16 '13 at 14:21
4

I have faced the same issue with IE 8 where the WebDriver was unable to click on any a href="" tag on the HTML page under test

The solution shessuky provided worked for me; That is setting BOTH ignoreZoomSetting and nativeEvents capabilities as follows

  • caps.setCapability("ignoreZoomSetting", true);
  • caps.setCapability("nativeEvents",false);
Salem Artin
  • 636
  • 6
  • 9
1

I think you may have to instantiate InternetExplorerDriver() using the parameter org.openqa.selenium.Capabilities as follows :

    DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
    caps.setCapability("ignoreZoomSetting", true);

    // Setting attribute nativeEvents to false enable click button in IE
    caps.setCapability("nativeEvents",false);
    WebDriver driver = new  InternetExplorerDriver(caps);

Hope this may help you;

Shessuky
  • 1,846
  • 21
  • 24
0

If you're running an automated Selenium test in IE11 with the browser window open on a touch screen monitor (e.g. Windows 8 touch laptop), try running the test with the browser window open in a non-touch screen.
The original .click() method should work fine without all the code workarounds.

See my full background answer https://stackoverflow.com/a/31397650/115704 on a similar StackOverflow question at Selenium 2.0b3 IE WebDriver, Click not firing.

Community
  • 1
  • 1
Jason Snelders
  • 5,471
  • 4
  • 34
  • 40
0

According to your HTML, the id is _ctl0_pageheader_login. It can be generated dynamically and may change.

You can try locating By.linkText("Login") or By.className("loginModal")

Sergii Pozharov
  • 17,366
  • 4
  • 29
  • 30
  • I might have confused the issue trying to scrub personal info out of my code. I am trying to find the button by .id = _ctl0_pageheader_login which I have not seen change and the code works fine in FF. I think in my stumbling around I tried to also find it by every other possible attribute as well but im happy to try again. The call also does not fail so its not like the .id changed and I get tossed into my catch block. it runs fine no errors it just never clicks on the link. and like I said above if I do a gettext it returns the proper text so it does find it – ducati1212 Jan 19 '11 at 21:08
  • It is not present in the HTML that you posted, but is there any probability that some JavaScript is attached to the login link? – Sergii Pozharov Jan 20 '11 at 15:38
  • there is no JavaScript on the login button. Since webdriver thinks it has the control and I assume thinks it fires off a click event is there a way to step through in debug mode the click event and see what its doing.? – ducati1212 Jan 21 '11 at 00:39
  • Do you have a 100% zoom set in IE? There are some bugs with this - inability to click some links when the zoom is not 100%. – Sergii Pozharov Jan 21 '11 at 12:36
  • Hey that worked for some reason my zoom was at 95% on to my next issue I will start a new thread for -> but in IE only again I cant seem to see (actually throws a unable to find element error) for items on a frame even after I do a driver.switchTo().frame("Loginiframe1_iframelogin"); IE developer tools does not seem to see individual controls in that frame either where firebug can. probably and IE thing but if it rings a bell please add a reply – ducati1212 Jan 24 '11 at 21:10
  • I never worked with IFrames and WebDriver, but you can search webdriver user group - I think I saw some questions about it - http://groups.google.com/group/webdriver – Sergii Pozharov Jan 26 '11 at 17:05
0

It might be something to do with the load speed, try adding an ImplicitlyWait

Selenium 2.0b3 IE WebDriver, Click not firing

Community
  • 1
  • 1
djeeg
  • 6,685
  • 3
  • 25
  • 28