我使用下面的输入在文本框中输入文本获取ElementNotVisibleException:当与XPath名称查找元素
driver.findElement(By.xpath("//input[@name = 'c_1']")).sendKeys("Test");
HTML:
<div id="ext-comp-1110" class=" x-panel criterion-block" style="width: 252px;">
<div id="ext-gen397" class="x-panel-bwrap">
<div id="ext-gen398" class="x-panel-body x-panel-body-noheader" style="width: 252px;">
<div id="ext-comp-1111" class=" x-panel criterion-label">
<div id="ext-gen413" class="x-panel-bwrap">
<div id="ext-gen414" class="x-panel-body x-panel-body-noheader">
<label id="ext-comp-1112">Insured Name contains:</label>
</DIV>
</DIV>
</DIV>
<input id="ext-gen186" class=" x-form-text x-form-field criterion " type="text" name="c_1" autocomplete="off" size="20" style="width: 222px;" title="">
</DIV>
</DIV>
当我运行这个我得到一个元素不可见的异常。
它不隐藏或隐藏任何隐藏的DIV。使用ID时可以达到同样的效果,但是这个ID在每次刷新时都会改变,所以用名称 – Srivardhan
检查您使用'driver.findElement(By.xpath(“// input [@name ='c_1']] “))。isDisplayed();' – Ievgen
有2个对象,当我检查大小,但当我检查显示我得到错误 – Srivardhan