Method Contains different from GetText

Method Contains different from GetText

Home Forums Ask Expert Method Contains different from GetText

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #32188
    Kirill Bulatnikov
    Participant

      Hello gabriel.fiel. Thanks for using ZAPTEST.

      I think VB Script function “replace” will help you! You need to replace possible spaces (” “) with null (“”) and then you can compare the content.

      Hope that helps.

      Thanks,
      Kirill.
      ZAPTEST Team.

      #32189
      Gabriel Fiel
      Participant

        Hi Kirill

        I am using javascript, so I tried Zap.Common.ReplaceSubString:

        var myVar= Zap.Common.ReplaceSubString(Application("My app").View("My View").Object("Text").GetText(), " ", "");

        if (myVar.Contains("20123.123")) {
        }

        I also tried this one:

        var myVar = Application("My app").View("My Viiew").Object("Text").GetText();
        var newVar = myVar.replace(" ", "");

        if (newVar.Contains("20123.123")) {
        }

        But it is not working, it shows an error when I try to use method Contains() with the variable (“O objeto não da suporte para a propriedade ou método”).
        Can you help me?

        Thank you.

        #32190
        Kirill Bulatnikov
        Participant

          Hey Gabriel
          First of all I have to admit that you are using GetText method improperly – to grab some text from the object you need to have real parent object for it otherwise ZAPTEST will not know where get text from and you will get empty value. And as soon as the value is null Contains method may output an error.

          Hope that helps.
          Thanks,
          Kirill.
          ZAPTEST Team

          #32191
          Gabriel Fiel
          Participant

            It was an example of how I am using it.
            I am using .Object(“parent”).Object(“son”).GetText() in the script.
            I get the text from the object, it is there, working.

            The problem here is with method Contains(), because in the documentation they use it with an object: Object(“x”).Contains(“something”).
            I am trying to use a variable instead: myVariable.Contains(“something”), is there a similar solution to solve this?

            Thank you 🙂
            Bye

          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.

          Virtual Expert

          ZAPTEST

          ZAPTEST Logo