I have the below element in the page I'm currently testing:
<li>
"At least 4 of the following rules must be satisfied:"
<br>
"Password should contain at least 1 upper latin characters (A-Z)"
<br>
"Password should contain at least 1 lower latin characters (a-z)"
"<br>
Password should contain at least 1 digits (0-9)"
<br>
"Password should contain at least 1 special characters: ! @ # $ % ^ & * ( ) _ + [ ] \ ; , . / { } | : " < > ?"
</li>
And I want to check, that each of the lines of text is shown in the page. Each line is not an element, but a text object, so after some searching I came to this [post][1]
, but the answer did not work as expected.
I used this chunk of code:
JavascriptExecutor javascriptExecutor = (JavascriptExecutor)driver;
String value = (String)javascriptExecutor.executeScript("document.evaluate(\"//*[@id='mainContainer']/form/div/div/div/div[2]/div/ul/li/text()[2]\", document, null, XPathResult.STRING_TYPE, null ).stringValue;");
System.out.println(value);
The xpath
works and points to the correct object, when checking in on Chrome
, but the print command prints null
. I know I cannot access the text node as a web element, so I wanted to pick every line separately and compare them with the relevant, expected, string (using soft assert
).
What am I doing wrong?