I am trying to verify the text but I get a message displayed saying "The information provided is either invalid or incomplete." I am using Selenium/WebDriver in Java.
I have the following HTML:
<div id="validationError">
<ul>
<li>Required: Server Name</li>
<li>Required: Receiving Port</li>
</ul>
</div>
CSS code is as follows:
#validationError:before {
content: 'The information provided is either invalid or incomplete.';
}
Java Code:
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());
The output of the above code is shown below:
Error Explanation:
Error: Required: Server Name
Error: Required: Receiving Port
Error Full Text: Required: Server Name
Required: Receiving Port
I can't find a way to verify the text "The information provided is either invalid or incomplete." is displayed. Calling getText() on the web element also does not return the expected string but will display any other normal text within that div. how to solve this?