I'm running a test using webdriver backed selenium and java to verify an error message containing % this is causing the test to fail.
I have tried to use the UTF-8 code ( \%
) but this also fails.
Code:
assertTrue(
Pattern.compile(
"Please enter a password of between 6 and 20 characters. You may use lower or upper case letters a-z, numbers 0-9 and the following characters !\"£$%").
matcher(
selenium.getText(
"//form[@id='registrationForm']/fieldset[3]/div/div[2]/div/p")).
find());
You are using a regex to match your strings (the $ means the end of a string/line)... if you really really want to use a regex I would recommend:
...
Pattern.compile(
"Please enter a password of between 6 and 20 characters\\. You may use lower or upper case letters a-z, numbers 0-9 and the following characters !\"£\\$%").
matcher(
...
Otherwise you could do:
assertTrue(
selenium.getText("//form[@id='registrationForm']/fieldset[3]/div/div[2]/div/p")
.contains(
"Please enter a password of between 6 and 20 characters. You may use lower or upper case letters a-z, numbers 0-9 and the following characters !\"£$%"
));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.