【问题标题】:css selector for the dynamic element动态元素的 CSS 选择器
【发布时间】:2016-01-14 06:42:51
【问题描述】:

我必须更新其元素 id 和名称随产品变化的产品的数量。 例如产品 1 id="数量_11046" 产品 2 id="quantity_15678"

我将 css 用作:

WebElement Qty=driver.findElement(By.cssSelector("div:contains(“quantity_1”)");

WebElement Qty=driver.findElement(By.cssSelector(""input[id$='quantity_1']");

但出现错误,无法找到元素。

<div>
<input type="number" maxlength="3" onkeypress="return isNumeric(event)" oninput="maxLengthCheck(this)" min="1" max="999" ng-model="qty" ng-blur="blurred()" ng-change="changed()" ng-disabled="disabled" ng-readonly="readonly" class="ng-pristine ng-untouched ng-valid ng-valid-min ng-valid-max ng-valid-maxlength" name="quantity_11046" id="quantity_11046">
</div>

【问题讨论】:

    标签: selenium selenium-webdriver css-selectors webdriver


    【解决方案1】:
    WebElement Qty=driver.findElement(By.cssSelector("input[id^='quantity_']")); 
    

    辛苦了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-09
      • 1970-01-01
      • 1970-01-01
      • 2013-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-16
      相关资源
      最近更新 更多