Forum Discussion

Adagio's avatar
Adagio
Frequent Contributor
7 years ago

Does VisibleOnScreen work for table rows?

Hello,

 

I'm trying to use VisibleOnScreen property in the code to check if the Row in a table is visible or not. Instead of returning a boolean value, it returns 'undefined'. is there something wrong that I'm doing here? 

  var newLastRowElement = page.FindChildByXPath(xPathOfLastRow);
  newLastRowElement.ScrollIntoView();
  Delay(1000);
  Log.Message("Last Row Visible: "+ newLastRowElement.VisibleOnScreen)

here's what I get in the logs: 

 

Last Row Visible: undefined

any help would be appreciated!

 

Thank you

Abhi

1 Reply

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Abhi,

     

    > var newLastRowElement = page.FindChildByXPath(xPathOfLastRow);

    You've trapped into one of several disadvantages of XPath...

    Description of the FindChildByXPath() method says that when an element is found by XPath, TestComplete tries to map this found element into the corresponding object of the Object Tree. If the mapping succeeds, then TestComplete returns the mapped object that has all additional properties that TestComplete adds (including VisibleOnScreen one). If the mapping fails, then TestComplete returns the 'raw' found object which, obviously, does not contain any additional TestComplete's method/property.

    Considering the above, the recommended practice is to use TestComplete's object search functionality (Aliases, FindXXX()) rather than XPath. XPath is the last resort method when nothing else works.

    If you are forced to use XPath, you can check if the found object supports Exists property (via the .IsSupported() method) and if it does, then this means that you are using TestComplete's object. If Exists property is not supported, this means that you are using 'raw' native object and can use only native methods/properties provided by this object.