Forum Discussion

elanto's avatar
elanto
Occasional Contributor
5 years ago

DelphiScript runtime error on: .GetColumn('name').Index

Hi SM-TestComplete Community,

First of all, here are some general info:

---

TC language: DelphiScript

Testcomplete Version: 14.20.2175.7 x64

OS: MS WIN 10 Pro 64-bit

The AUT (Desktop) is built in Delphi 7.

---

The object UT is a grid (inherited from TCustomGrid) and we want to get the column index like .GetColumn('name').Index + 1.

1. As we run the single script, it doesn't raise any exception, it works well.

The single script is of course one of a more complex test project.

2. But when we run the whole project then we got (see attached *.jpg) this DelphiScript runtime error Exception.

3. But this is further to consider: when we call exactly the same script in another TC-project in order to perform the foreseen actions (on the exactly same grid), in this case it doesn't raise any runtime exception. This is the main aspect we wish to clear.

The AUT (Desktop) is exactly the same.

In the attached file (*.jpg) you can see some more details of the our DelphiScript and runtime error.

Many thanks in advance and have a nice day

Best regards

Antonini E.

 

  • elanto's avatar
    elanto
    5 years ago

    I attached the same picture, maybe it is now better to see.

    The error text is: "An Exception occurred: 0xC0000096; class: ; description: ".

    <So, a copy/paste of your code snippet would be helpful.>

    -- START SNIPPET

    procedure einenBeliebigenMandantenLoeschenAberNichtDenDemoDatenMandanten();
    var
    i, mandantenAnzahl, ColumnVerzeichnisIndex: Integer;
    lVerzeichnis: String;
    const
    MAX_ANZAHL_MANDANTEN = 15;
    begin
    lVerzeichnis := ProjectSuite.Variables.DemoDatenMandantenPfad;

    if NOT Aliases.Lohn.FMandantenanlage.Exists then
    begin
    Aliases.Lohn.FSMenu.MDIClient.Keys('~fm');
    end;
    Aliases.Lohn.FMandantenanlage.Maximize;
    Aliases.Lohn.FMandantenanlage.Panel1.NO_1.TS_Mandanten.GR_Mandant.Keys('^[Home]');
    mandantenAnzahl := Aliases.Lohn.FMandantenanlage.Panel1.NO_1.TS_Mandanten.GR_Mandant.RowCounter;
    ColumnVerzeichnisIndex := Aliases.Lohn.FMandantenanlage.Panel1.NO_1.TS_Mandanten.GR_Mandant.GetColumn('Pfad').Index + 1;

    -- END

    Thank you.

    E.A.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    The image you have embedded is too small and is hard to read for the forum.  Could you attach the image rather than embed into your message or take the image at a higher resolution?

    Also, simply the error text would be helpful.

    Additionally, it would be good to know the code around it.  It might be that everything about the single line is just fine but the context in which it is called is problematic.  So, a copy/paste of your code snippet would be helpful.

    • elanto's avatar
      elanto
      Occasional Contributor

      I attached the same picture, maybe it is now better to see.

      The error text is: "An Exception occurred: 0xC0000096; class: ; description: ".

      <So, a copy/paste of your code snippet would be helpful.>

      -- START SNIPPET

      procedure einenBeliebigenMandantenLoeschenAberNichtDenDemoDatenMandanten();
      var
      i, mandantenAnzahl, ColumnVerzeichnisIndex: Integer;
      lVerzeichnis: String;
      const
      MAX_ANZAHL_MANDANTEN = 15;
      begin
      lVerzeichnis := ProjectSuite.Variables.DemoDatenMandantenPfad;

      if NOT Aliases.Lohn.FMandantenanlage.Exists then
      begin
      Aliases.Lohn.FSMenu.MDIClient.Keys('~fm');
      end;
      Aliases.Lohn.FMandantenanlage.Maximize;
      Aliases.Lohn.FMandantenanlage.Panel1.NO_1.TS_Mandanten.GR_Mandant.Keys('^[Home]');
      mandantenAnzahl := Aliases.Lohn.FMandantenanlage.Panel1.NO_1.TS_Mandanten.GR_Mandant.RowCounter;
      ColumnVerzeichnisIndex := Aliases.Lohn.FMandantenanlage.Panel1.NO_1.TS_Mandanten.GR_Mandant.GetColumn('Pfad').Index + 1;

      -- END

      Thank you.

      E.A.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Whoops!  Accidentally marked as solution... sorry...  

        In any case, a couple of things:

        1) You're doing a Ctrl-Home on the grid first.  I'm assuming that's doing some sort of refresh or other action?    Is it possible that the grid is not ready at that point for you to do the GetColumn information?  What's the value of mandantenAnzahl at that point?

        2) There could be other issues with the componet not being found, that it might not be ready at that point, taht you might have lost the handle, etc.  Try calling a RefreshMapping method off the grid before you do the GetColumn