我在发送按键输入时遇到问题。 当我调试我的应用程序时,输入存在,但是当我告诉他等到该元素可见时,它将引发Timeout Exception。 身份验证的输入工作正常,但在正常工作之前我的文件输入无法正常工作。
public void sendKeyOnElement(WebElement element, String string) {
try {
if (waitVisibilityOfElement(element)) {
if (element.getText().equals(""))
element.sendKeys(string);
else {
element.clear();
element.sendKeys(string);
}
} else {
System.out.println("Can't send keys element not visible");
}
} catch (ElementNotVisibleException v) {
System.out.println("Element Not Visible");
} catch (WebDriverException e) {
System.out.println("Can't send keys to the element " + element.getClass().getName());
}
}
public boolean waitVisibilityOfElement(WebElement element) {
try {
if (fluentWait == null || element == null)
System.out.println("SOMETHING IS NULL");
else
System.out.println("NOTHING IS NULL");
fluentWait.until(ExpectedConditions.visibilityOf(element));
System.out.println("Waiting visibility of element : " + element.getText());
return true;
} catch (TimeoutException e) {
System.out.println("Time out for visibility");
return false;
} catch (ElementNotVisibleException v) {
System.out.println("Element Not Visible");
return false;
} catch (NoSuchElementException u) {
System.out.println("Element does not exist");
return false;
}
}
有人可以帮我吗?