Forum Discussion

von_bailey's avatar
von_bailey
Contributor
12 years ago

Click method not actually clicking on item


I am attempting to run through a footer which has 32 links that are all identified in TC as "....Link(0) through ...Link(32)".  I have a loop that is supposed to sequentially click each one.  It clicks the first one fine, but the second creates an error as it's not actually clicking on the item it says it is (see image attached).  I have used "SetFocus" and I have forced a wait of up to 10 seconds after the item has already appeared on the screen and it still creates this error.  I'd appreciate any help.



function Swagbucks(theLink,browser,env)

  {

  try

    {

    Delay(2500)

    Sys.Keys("[PageDown][PageDown][PageDown][PageDown]")

    

    for(i=1;i<21;i++)

      {footerLink=theLink.Panel("sbFooterWrap").Panel("sbFooterContainer").Panel("sbFooter")

      if(footerLink.Link(i).Exists==true)

        {

        if(i>1){Sys.Keys("[PageDown][PageDown][PageDown][PageDown]")}

        theText=footerLink.Link(i).contentText+" footer link."

        Delay(10000)

        footerLink.Link(i).SetFocus()


        footerLink.Link(i).Click()

        Log.Message(theText)

        Delay(2500)

        }

      else

        {Log.Warning("Link was not  visible on screen for selection.")

        continue}

        switch(i)

        {

...

          default:

                theLink.Keys("[BS]")

                Delay(2500)

                continue

          }

        }}

  catch(e)

    {Log.Error("Failed Swagbucks Footer Column.")}

  }



 


3 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    You may need to upgrade to Test Complete version 10.20. I ran that exact script I provided on your main page and it worked flawlessly for me. I modified some of your code to fit my own purposes of testing and provide an example. You don't need to use it only showing that you should not have to page down to click the links nor perform several of the checks you had.
  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor


    Swagbucks('http://www.swagbucks.com/','chrome','');




    function Swagbucks(theLink,browser,env){


    try{


     for(var i= 0;i < 20;i++){


      Browsers.Item(browser).Navigate(theLink);


      footerLink= Sys.Browser(browser).Page('*').Panel("sbFooterWrap").Panel("sbFooterContainer").Panel("sbFooter");


      if(footerLink.Link(i).Exists && footerLink.Link(i).Visible){


       theText=footerLink.Link(i).contentText + " footer link.";


       footerLink.Link(i).Click();


       Log.Message(theText);


       }


      else{


       Log.Warning("Link was not  visible on screen for selection.");


       continue;


       }


      }


     }


    catch(e){


     Log.Error("Failed Swagbucks Footer Column.",e.message);


     }


    }


  • Thanks, but your solution appears to be to tie two different methods to ensure that the object is available, butthere is no problem finding and viewing the object.  The problem is, as the image shows, the click action is not on the object that it identifies and so is not acknowledged by the browser.