fbpx

GetText of object

GetText of object

Home Forums Ask Expert GetText of object

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31495
    Asif Qureshi
    Participant

      Hi ZapTest Team,

      I am about to ask a very basic question here because I have been stuck on this for a long time 🙁

      I have set a repository name “Invalid_Username_Message” and inside it I have to verify if label has text “Invalid Username” (I have named that label as “Invalid_Username_Message” as well)

      I am trying to print the message in a message box like below:
      msgbox Application(“Invalid_Username_Message”).View(“View”).Object(“Invalid_UserName_Message”).GetText

      but I am getting message box every time.

      I have following use case here:
      1. SignIn with empty username
      2. User should be able to see a message box “Invalid Username”
      3. If user doesn’t see this message, test should be failed, but next statement should get pointer (I don’t want to close my test here, i want to continue next test cases)

      Capture2.PNG

      Capture3.PNG

      I will be really grateful for your help 🙂

      Regards,
      AQU

      #31496
      Kirill Bulatnikov
      Participant

        Hello Aqu, thanks for your forum activity!

        In your case it will be enough to use Exist method for error message, I suppose. So if you expecting text “Invalid Username” just check if you already have object with matching Text property in repository (or create it manually). Then when you will need to use Exist method for this object and it report successful step in case if this object appears on the screen.

        Hope that helps.
        Thanks,
        ZAPTEST Team

        #31497
        Asif Qureshi
        Participant

          Hi,

          Thank you for your quick response.

          I had been trying with “Exist” method initially, but I am kind of stuck in there as well. Let me explain it to you.

          -> If NOT Application(“Invalid_Username_Message”).View(“View”).Object(“Invalid username i provided.”).Exist
          this statement returns “Run time error”
          The reason is that on UI, message was “Invalid username is provided” while I wanted to test the false scenario so I typed -> “Invalid username i provided”

          What I want to do is:
          1. Statement 1
          2. Statement 2
          3. Statement 3 (It fails, so log errors, and move to next Statement)
          4. Statement 4
          5. etc

          Capture4.PNG

          #31504
          Sasha ZAP
          Moderator

            Hello aqu,

            Basically the Exist method enables ZAPTEST to recognize the object, if there is no such object the Exist will fail.
            If you wish to do a GetText upon any message that appears in a specific place in the UI you should do the following:
            1. Set the object’s rectangle in the GUI Map to cover all appeared messages’ length.
            2. In the Object’s Property Set the “Recognition Type” property so it will be “Image”.
            3. Set a variable that will get the value the GetText method will capture and set a condition statement (If…Then) to check the text and send a report accordingly.

            If the GetText will capture more text then necessary you can always use the InStr method to check only a fragment of this text.

            P.S. Please download, install and use the latest ZAPTEST version (v17.4.0) which has number of new features and new fixes.

            Thanks,
            ZAPTEST Team

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

          Virtual Expert

          ZAPTEST

          ZAPTEST Logo