2015-09-08 70 views
-1

我要选择哪个定位器,以确定此按钮硒的webdriver按钮定位

<button 
    class="proceedButton btn-4 btn-4c icon-arrow-right btn btn-primary btn-lg btn-block width320 proceedButtonAnimate" 
    ng-click="validateAndProceedWeb(rechargeForm)" 
    data-horizontal="" 
    data-style="fill" 
    ng-disabled="checkoutDisable ? 'disabled' : ''" 
    tabindex="0" aria-disabled=""> 
     Proceed to Recharge 
     <span class="progress"> 
      <span 
       class="progress-inner" 
       ng-style="{width : (widthProgress + '%') }" 
       style=""> 
      </span> 
     </span> 
</button> 
+0

无法准确回答,除非我们可以看到整个DOM。在我们所知的所有DOM中可能还有其他相同的按钮。 – Ardesco

回答

0

proceedButton类的名称,而不是其他类名,是面向数据而不是布局为主。看起来可读性和可靠性:

driver.findElement(By.cssSelector("button.proceedButton")); 

你还不如用按钮的文本:

driver.findElement(By.xpath("//button[starts-with(., 'Proceed to Recharge')]"); 
0

使用XPath:

driver.findElement(By.xpath("//button[contains(@class,'proceedButton')]")); 
+0

谢谢它正在工作.. – abhiman

+0

在这种情况下,请将答案标记为有用(通过点击上方箭头)。 –