Forum Discussion

Raj_Qa's avatar
Raj_Qa
Contributor
13 years ago

Propoert checkpoint fails even though the innertext is same as expected

I am trying to verify some innertext on a web application, I am using the property checkpoint and tried using "Contains" and "Equals" but it fails, eventhough the expected and the actual value seems to be the same

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    My guess is that there is some non-printing character that is not included in your expected value but is present in your actual value.  Try removing all leading and trailing "spaces" from your expected value and use the "Contains" method of comparison.
  • Robert,



    There are some extra spaces in the inner text but I got rid of them, id I do not do so then testcomplete freezes or goes very slow. This  is what the actual property checkpoint looks like



    Call aqObject.CheckProperty(sys.process("firefox").page("*").document.all.Item("criteria"), "innerText", cmpContains, Chr(10)&"                                        Remove"&Chr(10)&"                                        "&Chr(10)&"                                            "&Chr(10)&"                                                Used,"&Chr(10)&"                                            Remove"&Chr(10)&"                                            "&Chr(10)&"                                                2009-2011"&Chr(10)&"                                            Remove"&Chr(10)&"                                            "&Chr(10)&"                                                Jaguar"&Chr(10)&"                                            Remove"&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                            "&Chr(10)&"                                                "&Chr(10)&"                                            "&Chr(10)&"                                        "&Chr(10)&"                                    ")











    But I got rid of those extra spaces in the hidden text .









    Call aqObject.CheckProperty(sys.process("firefox").page("*").document.all.Item("criteria"), "innerText", cmpContains,  "                                        Remove Used, Remove 2009-2011 Remove  Remove  ")
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Raj,



    When using the Equals or Contains comparison method, each character in the baseline value including extra spaces and line brakes (Chr(10)) in the middle of the value are significant. You can't simply remove them and expect the checkpoint to pass. For example, the string "AB CD" contains "B C", but doesn't contain "BC" — the same applies to checkpoints.



    To ignore the middle spaces, you need to verify innerText against a regular expression instead:

  • Helen,



    Thanks for the explanation. If i was able to use the entire expression as the expected value i would not have tried to alter it. But the expression is huge and Testcomplete crashes if I try to use it that way.

    I will use the other script you suggested



    Thanks for your help!