Forum Discussion

roytberA's avatar
roytberA
Occasional Contributor
8 years ago

ClickItem() does not work

I have script testing item with object.ClickItem("Item") that used to work before the update.   With the new update, it somehow does not work anymore. I have an error "Unable to perform the action because the control is invisible."  The object has the ClickItem methods listed, but does not work. 

 

I wonder if there a change on ClickItem() method?   The click() method does the click but I need to select one of the item there. I could map that item and just do the Click() twice but really don't want to.  There are other items that I have to change as well.  I tried increase delay between events, but didn't help. How do I get this ClickItem() to work again?  Thanks

12 Replies

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      The error "Unable to perform the action because the control is invisible." has nothing to do with what item is being selected but with the state of the control itself... apparently, at the time that the ClickItem is being attempted, the control being operated on is not visible.  This could be simply a timing issue where, when you perform an action against the application, there may be a delay between when that action completes and the dropdown control for ClickItem is visible on screen.

      • roytberA's avatar
        roytberA
        Occasional Contributor

        I think The error "Unable to perform the action because the control is invisible." is because the object was not clicked with ClickItem() method.  and the list of items in drowdown were invisible.  However, when use Click() the object was click and the dropdown was visilble to select item.  Then I will have to map the item to do another Click() method to get the actions I want.  Before the upgrade, it used to work just fine with one ClickItem(). 

         

        Can we add a delay in ClickItem() method?

         

        Thanks

  • roytberA's avatar
    roytberA
    Occasional Contributor

    So...I added Click() method, followed with ClickItem() and there is no error message but the script work inconsistently.  The ClickItem() sometime get skipped. 

            aqUtils.Delay(10000, "Wait for View");
        views_dropdown.Click(); 
            aqUtils.Delay(10000, "Wait for View");
        Log.Message(item);
        views_dropdown.ClickItem(item);    // work sometimes ,why???
        views_dropdown.ClickItem(item);    // this one works 

    Then, I added ClickItem() again to make sure the action is taken.  And I realized that I had to do the same thing on the other script with ClickItem() method a while back.  Because the first line is skipped and the second line works. 

      Aliases.browser....ClickItem(year); // this line sometime get skipped , not sure why????
      Aliases.browser....ClickItem(year);

     Having 2 lines of ClickItem() seems to be a workaround for this issue.  The other project also experiences this issue as well.  

    • cunderw's avatar
      cunderw
      Community Hero

      Instead of doing two ClickItems as a work around can you try something like:

       

      views_dropdown.WaitProprety("Exists",true,10000);
      views_dropdown.WaitProprety("Visible",true,10000);
      views_dropdown.WaitProprety("Enabled",true,10000);
      views_dropdown.ClickItem(item);  

      That many waits might be overkill, but should at least tell us if it's a timing issue like tristaanogre mentioned. 

      • roytberA's avatar
        roytberA
        Occasional Contributor

        Thank you cunderw  

         

        I ran your code, the log message says "Unable to perform the action because the control is invisible." , no error before that. 

         

        I don't believe it is the time issue.  the same object can do Click() but right after that cannot ClickItem(). I think it is something to do with the ClickItem().  I have found that i had to do ClickItem() twice to make sure the action really happens it the other 3 scripts.  Also another project has the same issue with ClickItem() sometimes get skipped as well.  

         

        When I have 2 lines of ClickItem()s, if they both work, the ClickItem() happens twice. The log message shows 2 Event. 

        When one does not work, (usually the first line) it just get skipped and the second line does the ClickItem(), with no error message. The log message only shows 1 Event. 

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      More and more this looks like a timing issue of some sort... that the object you're trying to execute "ClickItem" against is not ready to be clicked.  The page is not loaded or the object is not refreshed or something.  Can you post the full code from your test leading up to your attempt to use "ClickItem"?  I'd like to see what's being called, how it's being called, etc.  Web pages are trickey, sometimes... you have to remember that, when you are manually doing things, you take your cues from the screen as to when something is ready to be interacted with.  TestComplete needs to be told to be similarly "smart" about things... there are "Wait" methods that you should call at various points in your test that are not necessarily part of initial recording.  And, if you're manually writing code, you need to make sure you add them manually.

       

      So... share your code and we'll take a look and see what can be improved... basically, everything you've described is symptomatic of attempting to operate on a control that has not been fully loaded/rendered/refreshed by the browser... So, we need to fix that... it's not a problem with ClickItem specifically....

       

      To anticipate your question as to why it suddenly stopped working.... browsers update, browsers change, AUT's change, database servers change, etc... and not always under our control.  So... let's start with what we DO have control over, that being how the automation code detects when to move on to the next operation.