Forum Discussion

Lagencie's avatar
Lagencie
Frequent Contributor
4 days ago

NG-Translate hyphenation breaking contentText

Hello, 

perhaps someone experienced the same problem already - we are using contentText quite often in our testsuite and the developers updated their code lately and they now used the ng-translate hyphenation so that the text get shown better on the UI to the customer.

But with this we now have the problem, that many contentTexts now look like the one above "th-is is a co-mp-le-te-ly new te-xt" ... our testing team that uses cypress had a very easy way to adapt their code, as they only added one global function that changes contenttexts with replace("-", "") and it worked again ... but with TestComplete we could for sure do this single step before each use, but we would need to adapt like thousands of teststeps which would take us weeks if not months to adapt..

Is there a way / any setting or something you know in TestComplete that can handle this behaviour?

best regards
Dominik

5 Replies

  • Lagencie's avatar
    Lagencie
    Frequent Contributor

    yes its a web application, but I do not think that this would help. We are mapping our objects with test-id html attribute so this is not affected, but the problem is the content text which now looks 

    like this for example ... in this case Startup and Reconnection ... and we have some test steps in this case that check for the .contentText of the mapped object and compares those headlines ... but the contentText now is this text with the ­ in the text everywhere. Also if we test textfield inputs / outputs against a database of values for example those run all red now because of this hyphenation

    • rraghvani's avatar
      rraghvani
      Champion Level 3

      TC is correctly identifying the object, based on contentText property value as shown in your HTML screenshot. I could be wrong, but I very doubt that this can be translated into something meaningful. 

      May be someone else might be able to help here. Sorry

       

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Dominik,

     

    Did I get it right that .contentText is used for text comparisons only and not for objects identification in NameMapping?

    If my understanding is correct, why not to create, say, TextUnhyphenate(strValue) function that will do exactly what your guys did for Cypress and wrap all calls to xxx.contentText with this function?

    E.g.:

    if (strValueFromDB == TextUnhyphenate(someUIobject.contentText)) {...}

    I think that you even can create a regular expression to wrap everything that ends with .contentText with a call to the function.

     

    Another possible option might be to use some other property that contains same value as .contentText but without hyphenation and use this property instead of .contentText.

     

    • Lagencie's avatar
      Lagencie
      Frequent Contributor

      yeah you understood it correctly.

      The notepad replace over all files with a function like that was our first in mind option also, but I was somehow hoping that there might be a setting / property whatever to check in testcomplete where we can make it like "shy hyphenation on" or whatever so it automatically turns those ­ into nothing by default as it is a very common used hyphenation option within angular / ng