首页 > 解决方案 > 如果 HTMl 没有值,则无法读取文本字段值

问题描述

我正在尝试读取文本值,但由于 HTML 中没有值而无法读取,我附上 HTML plz 看看这个并建议如何读取文本值。

<table class="table table-striped">
  <tr>
    <td class="letter">A.</td>
    <!---->
    <td class="one">Length<input min="0" onkeypress="return (event.charCode >= 48 &amp;&amp; event.charCode <= 57) || event.charCode == 32 || event.charCode == 0 || event.charCode == 46" step="1" type="text" class="ng-pristine ng-valid ng-touched"> ft</td>
    <!---->
    <td class="two"><input max="11" min="0" onkeypress="return (event.charCode >= 48 &amp;&amp; event.charCode <= 57) || event.charCode == 32 || event.charCode == 0 || event.charCode == 46" step="1" type="text" class="ng-untouched ng-pristine ng-valid"> in</td>

在检查元素后,该值不存在于 HTML 中。

标签: javascriptjavahtmlseleniumselenium-webdriver

解决方案


在这些事件处理程序中,该值可以作为this.value. this指事件处理程序所在的元素,并且value是包含字段当前值的属性(在 DOM 树本身中未显示)。


推荐阅读