Forum Discussion

Petewilson's avatar
Petewilson
Contributor
6 years ago

Menu not selected as TC reports as not visible on screen, but i'm looking right at it.

Bit of an unusual one here and i'm very confused.

 

The below code is run and searches for and selects the menu item detailed.

The code is used several times in a loop to build a system, so it searches and selects, 'Color', 'Projection', Wall Height' etc.

 

Oddly on the 7th and 8th loop system it builds, it searches for 'Flooring' finds it, but then can't select it as it reports it is waiting for it to be visible on screen.

 

What is strange is that i can see it on screen, it knows it is there as it fails at the touch command, using the object spy reports it as being visible on screen, but for some reason the Watch details for it show as False for Visible on screen.

 

Of the 16 systems it builds it is fine for all the rest

 

 

procedure Find_Label_Touch(ControlName : String; Driver: OleVariant);
var
  target_CollectionView;
  target_Label;
  Value;
begin
  Value := Project.Variables.Driver.Value(ControlName);
  If Value <> 'Blank' then 
  begin
    target_CollectionView := Aliases.Device.processApplication.window0.tableview0;
    target_Label := target_CollectionView.Find( ['ObjectType', 'ObjectText'], ['Label', Value], 20000);
    target_Label.Touch();
    Delay(500);
  end;
end;
  • Thank you both and apologies for the late feedback.

     

    I have a feeling that it is some sort of delay in the screen displaying what it is looking for although i am not sure why it is only affecting that particular menu item, since they all run the same code, just with a different param to tell it what text to search for. I have increased my delays in the script and it appears to now be fine for 15 out of 16 loops.

     

    Thank you both for the input as it gave me other avenues to look at.

  • LinoTadros's avatar
    LinoTadros
    Community Hero

    I have seen that behavior before on complex 3rd party controls, which looks like that is the case here.

    With complex controls like the menu you are using, the developers are using the internal collection of the object, display it on the screen, then remove the object from memory on purpose or the garbage collector removes it in Java or .NET as the UX portion of the control is not referenced again anywhere.

     

    So in you case, the collection is there but the labels are not.  I know you can see the labels on the screen and that is part of the rendering the control is doing but the objects are no longer there, so the "Touch" on the label is failing.

     

    These type of issues can be resolved in one of 3 ways:

    1- Fire the click procedue on the Collection item itself in script

    2- Low Level Procedure to click on the label on the screen which will trigger an event even though the object underneath it is not in memory

    3- Use the new OCR (Artificial Intelligence) in TestComplete 12.5 and 14 to recognize the label text in the menu and fire a click command on it.

     

    Hope that helps

    -Lino

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > object spy reports it as being visible on screen, but for some reason the Watch details for it show as False for Visible on screen.

     

    VisibleOnScreen is a property that should be used with caution... As it is said in the documentation, VisibleOnScreen is set to True only when the object is visible on screen at the given moment of time. Which means that if the object (control) is overlapped (for example, by TestComplete's UI), its VisibleOnScreen will be set to False. (And back to True if you switch back to the tested application itself). This fact makes debugging of the code that uses VisibleOnScreen a bit problematic (unless you have more than one monitor, so that your tested application is always visible).

    One more thing - VisibleOnScreen originates from desktop/web support and personally I would be not much surprised if it has some side effects/specifics on mobiles.

    Another thing to consider: wasn't the tested menu scrolled in some way before test code attempted to touch its Flooring item? If it was, then using what means? If the scroll was done from test code via the direct call to some native methods, then it could be that scroll action was not noted by TestComplete and it still considers menu item as not visible on screen.

    And the last one for the moment: try to examine in the Object Browser objects that are close to the problematic menu item. It is quite possible that, for example, the item with the Autumn Landscape text overlaps menu item and thus it is considered as not visible on screen. (For example, it may be not clear to TestComplete that the text has transparent background which makes menu item to be visible.)

     

    • Petewilson's avatar
      Petewilson
      Contributor

      Thank you both and apologies for the late feedback.

       

      I have a feeling that it is some sort of delay in the screen displaying what it is looking for although i am not sure why it is only affecting that particular menu item, since they all run the same code, just with a different param to tell it what text to search for. I have increased my delays in the script and it appears to now be fine for 15 out of 16 loops.

       

      Thank you both for the input as it gave me other avenues to look at.

      • Linda95's avatar
        Linda95
        Occasional Visitor

        @MyPrepaidBalance wrote:

        Thank you both and apologies for the late feedback.

         

        I have a feeling that it is some sort of delay in the screen displaying what it is looking for although i am not sure why it is only affecting that particular menu item, since they all run the same code, just with a different param to tell it what text to search for. I have increased my delays in the script and it appears to now be fine for 15 out of 16 loops.

         

        Thank you both for the input as it gave me other avenues to look at.


        Which means that if the object (control) is overlapped (for example, by TestComplete's UI), its VisibleOnScreen will be set to False. (And back to True if you switch back to the tested application itself). This fact makes debugging of the code that uses VisibleOnScreen a bit problematic (unless you have more than one monitor, so that your tested application is always visible).

        One more thing - VisibleOnScreen originates from desktop/web support and personally I would be not much surprised if it has some side effects/specifics on mobiles.

        Another thing to consider: wasn't the tested menu scrolled in some way before test code attempted to touch its Flooring item? If it was, then using what means? If the scroll was done from test code via the direct call to some native methods, then it could be that scroll action was not noted by TestComplete and it still considers menu item as not visible on screen.