【问题标题】:selenium firefoxdriver tests can`t click buttonselenium firefoxdriver 测试无法点击按钮
【发布时间】:2011-11-11 13:01:26
【问题描述】:

我正在使用 selenium 和 firefox 驱动程序,我无法使 <span>close</span>button 进行单击。我尝试了不同的方法:

1 selenium.mouseDownAt("link=close", "10,10"); selenium.mouseUpAt("link=close", "10,10");

2 driver.findElementByPartialLinkText("close").click();

3 selenium.focus("link=close"); seleleniumkeyPress("link=close", "r");

4 actions.click(driver.findElementByPartialLinkText("close")).perform(); actions.release(driver.findElementByPartialLinkText("close")).perform();

但它不起作用。我能看到的唯一效果是按钮似乎被单击并按住,但没有释放。这就是为什么我尝试通过方法1和4来做到这一点。

但我仍然无法单击它,因此可以看到一个弹出窗口。

有人知道可能是什么原因吗?

html代码:

<div id="id_asd83221" class="sub-tbl-content sub_position">             
     <div class="sub-order-pos-firstpart">       
      <div class="float pic-content sub-img sub-img-arrow-down"></div>      
       <div class="float sp_id_content">some text</div>    
         <div class="float type-sub-content">some text</div>     
        <div class="float amount-sub-content">some text</div>   
          <div class="float pl-sub-title">some text</div>      
       <div class="float pl-sub-content">some text</div>     
       </div>     
        <div>           
  <div class="float"><a class="small-tbl-button  sp_close_positon_btn" href="#">
<span>close</span></a></div>      
       <div class="floatright edit-sub-content">
<a class="sp_edit_position_link" href="#">some text</a></div>                                                                                                    </div>           
  <div class="clear0"></div>     
   </div>

【问题讨论】:

    标签: java selenium automated-tests webdriver


    【解决方案1】:

    你的每一个例子都点击了,但应该在的问题。 尝试使用 xpath //a/.[contains(text(),'close')]/.. 或者您也可以尝试开启启用本机事件。

    【讨论】:

      【解决方案2】:
      driver.FindElement(By.CssSelector("a[class='sp_close_positon_btn'] span")).Click();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-29
        • 1970-01-01
        • 1970-01-01
        • 2015-04-25
        • 1970-01-01
        相关资源
        最近更新 更多