I have a test where it would verify to see if the username will display where the login and log out is. Here is the object html.
<span class="MuiButton-label"><svg class="MuiSvgIcon-root" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"></path></svg> CLARA ADAMS (autotest) ▼</span>
I copied the element
<span class="MuiButton-label"><svg class="MuiSvgIcon-root" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"></path></svg> CLARA ADAMS (autotest) ▼</span>
Here is my code , and it kept on printing Fail which make me believe that it could not match the text. I also noticed that when it print out the values instead of the ▼ it printed out as CLARA ADAMS (autotest)?
How can I modify my code so that I could recognize CLARA ADAMS (autotest) ▼?
// Get the Text from the location
if (driver.findElement(By.className("MuiButton-label"))
.getText().equalsIgnoreCase("CLARA ADAMS (autotest) ▼")) {
System.out.println("CLARA ADAMS (autotest) ▼ Pass");
} else {
System.out.println("CLARA ADAMS (autotest) ▼ Fail");
}