无法输入值以输入文本框

时间:2014-12-18 17:48:28

标签: selenium capybara

我需要帮助解决如何输入值以输入与表格td中包含的表格单元格相关联的文本框

html是:

<td role="gridcell">
  <span style="width: 95px;" class="k-widget k-numerictextbox campaignBid">
    <span class="k-numeric-wrap k-state-default">
      <input type="text" class="k-formatted-value campaignBid k-input valid" tabindex="0" style="display: inline;" aria-disabled="false" aria-readonly="false">
      <input type="text" style="display: none;" value="0.0079" class="campaignBid k-input valid" id="mb_2" data-role="numerictextbox" role="spinbutton" aria-valuemin="0.0079" aria-valuemax="1" aria-valuenow="0.0079" aria-disabled="false" aria-readonly="false">
      <span class="k-select"><span class="k-link" unselectable="on"><span title="Increase value" class="k-icon k-i-arrow-n" unselectable="on">Increase value</span></span><span class="k-link" unselectable="on"><span title="Decrease value" class="k-icon k-i-arrow-s" unselectable="on">Decrease value</span>
      </span>
    </span>
   </span>
  </span>
</td>

我尝试过使用构建器执行:     bvar = first(:xpath, "/td[7]/span/span/input")     builder=page.driver.browser.action     builder.key_down(:control).click(bvar.native).send_keys('a').send_keys("#{value}").perform sleep of 1秒,但不起作用,我不能单独输入值,每次加上“0”。在代码的开头。

任何帮助都将受到高度赞赏。

<td role="gridcell"><span style="width: 95px;" class="k-widget k-numerictextbox campaignBid"><span class="k-numeric-wrap k-state-default"><input type="text" class="k-formatted-value campaignBid k-input valid" tabindex="0" style="display: inline;" aria-disabled="false" aria-readonly="false"><input type="text" style="display: none;" value="0.0079" class="campaignBid k-input valid" id="mb_2" data-role="numerictextbox" role="spinbutton" aria-valuemin="0.0079" aria-valuemax="1" aria-valuenow="" aria-disabled="false" aria-readonly="false"><span class="k-select"><span class="k-link" unselectable="on"><span title="Increase value" class="k-icon k-i-arrow-n" unselectable="on">Increase value</span></span><span class="k-link" unselectable="on"><span title="Decrease value" class="k-icon k-i-arrow-s" unselectable="on">Decrease value</span></span></span></span></span></td>

1 个答案:

答案 0 :(得分:0)

你应该只是做

find(:xpath, "/td[7]/span/span/input[1]").set "" 
find(:xpath, "/td[7]/span/span/input[1]").set "Your value" 

清除现有值的第一行