【发布时间】:2013-11-06 10:20:52
【问题描述】:
我使用 selenium webdriver 最新版本。
Selenium 找不到元素(输入字段)。这是html代码:
<input id="findPath" class="pathCom" type="text" style="width: 100%;
background-color: rgb(255, 255, 255);" name="$path$conFind"
value="find" data-ctl="["TextInput"]">
我使用这样的硒代码:
driver.findElement(By.xpath(".//input[@id='findPath']")).sendKeys("find");
我也尝试通过 id 或 css 定位器查找。我在这段代码之前设置了等待:
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(" driver.findElement(By.xpath(".//input[@id='findPath']")).sendKeys("find");")));
我尝试使用 Selenium IDE,它找到了这个元素。我不知道 webdriver 有什么问题。 有人遇到过这样的问题吗?
【问题讨论】:
-
尝试删除开头的“.”并仅使用“//input[@id='findPath']”。
-
这个我试过了,谢谢
标签: html eclipse selenium-webdriver element