为了账号安全,请及时绑定邮箱和手机立即绑定

org.openqa.selenium.TimeoutException:

org.openqa.selenium.TimeoutException:

慕村225694 2022-08-03 16:26:24
我正在尝试使用选项发送文本。这是我的类页面对象中的方法案例:sendkeys()public void setEntityName() {    internalWait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"entity_name\"]")));    entityName.clear();    entityName.sendKeys("TEST");}网页: <input id="entity_name" name="entity_name" type="text" ng-model="entityData.name" ng-disabled="false" placeholder="Type Enity Name" data-maxlength="20" data-smart-validate-input="" data-required="" class="ng-pristine ng-invalid ng-invalid-required ng-valid-maxlength ng-touched">测试显示错误org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath: //*[@id="entity_name"] 任何人都可以帮助我解决此错误。
查看完整描述

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");

}


查看完整回答
反对 回复 2022-08-03
  • 1 回答
  • 0 关注
  • 404 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信