fbpx

Try Catch

Try Catch

Home Forums Ask Expert Try Catch

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31951
    Nuno Seixas
    Participant

      Hi there,

      I’m trying to select a date from a Calendar using your example (with a table). However if I what to select a pre-selected date I can’t because on my app it will be displayed like [8] instead of 8 and ZapTest can’t find it. I tried to use a Try Catch to select another date case mine was pre-selected (not found) but no success because the catch never run.

      Any idea how to solve that?

      try{
      Application("Myapp").View("SelDate").Object("Calendar").Table("Date").ClickCell(Datatable.Value("Date"));}
      catch(e){
      Application("Myapp").View("SelDate").Object("Calendar").Table("Date").ClickCell(Datatable.Value("Date"));}

      #31952
      Sasha ZAP
      Moderator

        Hello nuno.seixas,

        There are 3 options you can try in order the Table object will recognize its specific cell:

        1. Add the Boolean statement “True” at the end of the code line, this will ensure the Table object will be set to handle a Web Calendar object type:
        Application(“Myapp”).View(“SelDate”).Object(“Calendar”).Table(“Date”).ClickCell Datatable.Value(“Date”), True

        2. Use the same “Clickcell” method’s attributes but this time instead of using the cell number use string such as:
        Application(“Myapp”).View(“SelDate”).Object(“Calendar”).Table(“Date”).ClickCell “[8]”, True

        3. Basically there are another “Clickcell” method’s attributes, which help locate the specific cell by its row and column, you can set them instead of the specific column’s cell text – For example today’s date (The 10th of July) in the Windows’ OS based calendar it will be the row 3 and the column 3, so if you’d like to click on it your code will be:
        Application(“Myapp”).View(“SelDate”).Object(“Calendar”).Table(“Date”).ClickCell 3, 3

        Hope this helps.

        Thanks,
        ZAPTEST Team

        #31953
        Nuno Seixas
        Participant

          Hello SashaY,

          Thanks for your answer.
          Problem is, I never know if the date what I want to pick from the calendar has the [] or not.
          For example, if I want 4, I don’t know if in the calendar I have 4 or [4].
          I want something like if(4 exist) {sel 4} else { sel [4] }

          Thanks.

          #31954
          Sasha ZAP
          Moderator

            Hello nuno.seixas,

            Basically you can add a similar condition as the following one:

            bFound = False
            intNumofRows = Application(“Myapp”).View(“SelDate”).Object(“Calendar”).Table(“Date”).GetRows
            inNumoftColumns = Application(“Myapp”).View(“SelDate”).Object(“Calendar”).Table(“Date”).GetColumns
            For i = 1 To intNumofRows
            For j = 1 to inNumoftColumns
            strCellText = Application(“Myapp”).View(“SelDate”).Object(“Calendar”).Table(“Date”).GetCellText(i, j)
            If InStr(strCellText, “8”) Then
            bFound = True
            Application(“Myapp”).View(“SelDate”).Object(“Calendar”).Table(“Date”).ClickCell i, j
            Exit For
            ElseIf InStr(strCellText, “[8]”) Then
            bFound = True
            Application(“Myapp”).View(“SelDate”).Object(“Calendar”).Table(“Date”).ClickCell i, j
            Exit For
            End If
            Next
            If bFound = True Then
            Exit For
            End If
            Next
            If bFound = False Then
            Application(“Myapp”).View(“SelDate”).Object(“Calendar”).Table(“Date”).Report False, “Cell Error”, “The cell ‘8’ or ‘[8]’ was not found.”, True
            End If

            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