Pregunta

he estado escribiendo mis guiones para FF, pero esperaba con poco trabajo que también se ejecutará en los otros navegadores, pero parece IE conductor tiene problemas con los botones?

Tengo un webelement.click sencilla () en un botón que no tira un error pero no haga clic en el botón. en FF está bien. Puedo conseguir texto, obtener el valor así que sé la declaración hallazgo está bien simplemente no haga clic en él.

pensamientos o ayuda sería grande

Sólo haciendo

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

HTML - El control tiene 3 botones en él sólo me interesa por ahora con el inicio de sesión

<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>     
¿Fue útil?

Solución

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!

Otros consejos

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.

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);

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;

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")

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

Selenium 2.0b3 IE WebDriver, Click not firing

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top