我正在尝试验证文本"提供的信息无效或不完整".在Java中使用Selenium/WebDriver显示.
我有以下HTML:
<div id="validationError">
<ul>
<li>Required: Server Name</li>
<li>Required: Receiving Port</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
使用以下CSS代码:
#validationError:before {
content: 'The information provided is either invalid or incomplete.';
}
Run Code Online (Sandbox Code Playgroud)
这是我目前的java代码:
WebElement errorBox = browser.findElement(By.id("validationError"));
Assert.assertNotNull("Could not find validation errors", errorBox);
System.out.println("Error Explanation: " + error.getCssValue("content") + "\n");
List<WebElement> errorList = errorBox.findElements(By.tagName("li"));
for (WebElement error : errorList) {
System.out.println("Error: " + error.getText());
}
System.out.println("\nError Full Text: " + errorBox.getText());
Run Code Online (Sandbox Code Playgroud)
这是我输出的上述代码:
Error Explanation:
Error: Required: Server Name
Error: Required: Receiving Port
Error Full Text: Required: …Run Code Online (Sandbox Code Playgroud)