1 回答
TA贡献1982条经验 获得超2个赞
所需的元素是一个 Angular 元素,因此要调用而不是您必须诱导 WebDriverWait for 和 您可以使用以下任一解决方案:sendKeys()visibilityOfElementLocated()elementToBeClickable()
用:cssSelector
public void setEntityName() {
WebElement entityName = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.ng-pristine.ng-invalid.ng-invalid-required.ng-valid-maxlength.ng-touched#entity_name[ng-model='entityData.name']")));
entityName.clear();
entityName.sendKeys("TEST");
}
用:xpath
public void setEntityName() {
WebElement entityName = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@class='ng-pristine ng-invalid ng-invalid-required ng-valid-maxlength ng-touched' and @id='entity_name'][@ng-model='entityData.name']")));
entityName.clear();
entityName.sendKeys("TEST");
}
添加回答
举报