0

我面临一个奇怪的问题,即我的脚本无法在搜索条件屏幕中输入数据。
注意:这是同一个屏幕,不是弹出窗口或新窗口。它只是导航到具有相同 webdriver 实例的其他屏幕

HTML:

<td class="dataCol requiredInput">

<input tabindex="1" maxlength="40" type="text" id="search_criteria" size="20" name="search_criteria" value="">

</td>

我使用的代码:

LoginPage2.driver.findElement(
  By.xpath("//input[@id='search_criteria']")
).sendKeys("test")

我正在使用 Selenium 2.25.0

观察:在 HTML 语法如下所述的字段中写入文本值时,我没有遇到任何问题:

<*td class="dataCol col02">
<*input id="00N20000001LwsL" maxlength="20" name="00N20000001LwsL" size="20" tabindex="6" type="text">
<*/td>

我不确定这是因为 HTML 格式还是代码的构建方式。

如果我遗漏了什么,请告诉我?我也By.name试过

4

2 回答 2

0

尝试在 xpath 上更具体,多个元素可能对应于同一个 xpath。也许尝试:

"//td[@class='dataCol requiredInput']/input[@tabindex='1' and @id='search_criteria']"
于 2013-01-03T22:26:46.867 回答
-1
driver.findElement(By.name("password")).sendKeys("ccc");
于 2014-04-10T07:00:40.340 回答