【发布时间】:2020-07-17 19:10:13
【问题描述】:
我正在尝试将信息发送到文本字段,但我很难找到它。有多个同名元素,很难找到。
<div class="form-group">
<label for="username">LDAPTEST Username</label>
<input type="text" name="username" id="username" class="form-control top" title="This field is required." autofocus="autofocus" data-qa-selector="username_field" required="required">
<p class="gl-field-error hidden">This field is required.</p>
</div>
我尝试了以下方法:
username_By = By.id("username")
username_By = By.cssSelector("input[data-qa-selector='username_field']")
我在等待元素可见时遇到 TimeoutException。
wait.until(ExpectedConditions.visibilityOfElementLocated(username_By));
关于如何定位元素的任何建议?谢谢
【问题讨论】:
标签: java selenium xpath css-selectors webdriverwait