信息:
我从配置文件中获取了fieldXpath
,它是"//input[@id='signin_password']"
HTML:
<li><input type="password" name="signin[password]" id="signin_password" /></li>
工作原理:(但并非总是如此)
进入陷阱...
public void doAction(WebDriver driver) throws TestException {
try {
WebElement el = driver.findElement(By.xpath(fieldXpath));
el.clear();
el.sendKeys(fieldValue);
} catch (Exception e) {
throw new TestException(this.getClass().getSimpleName() + ": problem while doing action : " + toString());
}
}
这个代码能否使用XPath实现?