3

I am trying to get text from a field that contains diacritics like: ă,ă-Ă-â-Â-î-Î-ş-Ş-ţ-Ţ web page source

My method for get text looks like this:

    public  void invalidEmailValidation(){
    String expectedInner = LoginPage.invalidMailMessage(driver).getAttribute("innerText");
    String expectedText =  LoginPage.invalidMailMessage(driver).getText();
    System.out.print("EXPECTED1: " + expectedInner + "\n" +
                     "EXPECTED2: " + expectedText );
    Assert.assertEquals("Expcted Inner: Adresa de email nu este validă",
            expectedInner, "Adresa de email nu este validă");
    Assert.assertEquals("Expcted text: Adresa de email nu este validă",
            expectedText, "Adresa de email nu este validă");

The output from the method is here: console output

I mention that my project have UTF-8 encoding project encoding: UTF-8 Also UTF-8 encoding is added in pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

Other informations: IDE: IntellijIdea 14.1.4 (comunity version) OS: Windows 7 (english language as default) I already checked the following questions from StackOverflow: Cannot verify text with diacritics Empty string

Community
  • 1
  • 1
vasilev21
  • 113
  • 2
  • 4
  • 15
  • In the middle of your screenshot where the expected and actual text is printed, there is a link that states . What does it display? I'm just wondering if there is some character in there like a non-breaking space or something that is different other than the letters. – JeffC Sep 03 '15 at 00:50
  • @JeffC It says that strings are identical, and the string that is compared is "Adresa de mail nu este valid?" – vasilev21 Sep 03 '15 at 12:34
  • It's failing because the strings are not the same. If you click to see the difference, it doesn't show anything? It may be that there are non-printable characters in there that are causing it to fail. You could do a character by character comparison of the two strings and log the ASCII codes of each. That should help you determine where the failure is. – JeffC Sep 03 '15 at 16:32

0 Answers0