selenium webdriver IE button issue

2019-03-21 21:47发布

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>     

7条回答
Anthone
2楼-- · 2019-03-21 22:22

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;

查看更多
登录 后发表回答