Forum Discussion

dvox's avatar
dvox
Occasional Contributor
14 years ago

Click on dynamic link with static name

I am using tree model for my scripts. I have a link which has a static text as "Delete Folder". But recording the same gives a different name everytime since the ID associated to the folder is unique for every transaction. 



To do this, I used the following to code to confirm that the object actually exists. But I am not sure, how to click on this object. Would appreciate any help. I am also putting down the html code of the link. Hope that might help you in guiding me.




 



   if(aqString.Find(iexplore.pagemyprojectshare2.formAspnetform.innerHTML, "Delete Folder")!= -1)

  {

    Log.Message("Object found");

  }





HTML






<li>




<a href="#" onclick='DeleteFolder();return false;'><img src="/App_Themes/Main2_0/images/ico-delete.png" style="margin-right:5px;" />Delete Folder</a>




</li>



3 Replies

  • Hi,



    Use the Find method (not aqString.Find) - search by the innerText property value (see the "Find Method" help topic).
  • dvox's avatar
    dvox
    Occasional Contributor

    This is what i tried to use. Did I miss any thing. I am trying to click on a link "Delete Folder".





    function Test122() 



      var p = Sys.Process("iexplore"); 

      var page = p.Page("https://testingmysite.com/You/MyActivities?FolderID=60576"); 





     var PropArray = new Array("href", "#"); 



      var ValuesArray = new Array("a", "Delete Folder");  









      var ConvertedPropArray = ConvertJScriptArray(PropArray); 

      var ConvertedValuesArray = ConvertJScriptArray(ValuesArray); 

       

      var MyLink = page.Find(ConvertedPropArray, ConvertedValuesArray, 5); 

      if (MyLink.Exists) 

        Log.Message("Object found", MyLink.FullName); 

      else 

        Log.Error("The object is not found"); 











    function ConvertJScriptArray(AArray) 



      // Uses the Dictionary object to convert a JScript array 

      var objDict = Sys.OleObject("Scripting.Dictionary"); 

      objDict.RemoveAll(); 

      for (var j in AArray) 

        objDict.Add(j, AArray); 

      return objDict.Items(); 





    The source for this link is as follows.








    <li>




    <a href="#" onclick='DeleteFolder();return false;'><img src="/App_Themes/Main2_0/images/ico-delete.png" style="margin-right:5px;" />Delete Folder</a>




    </li>






  • dvox's avatar
    dvox
    Occasional Contributor
    Never mind. Got it. 



    used the following and worked. Thanks for your help.



    var obj = page.FindChild("innerText","Delete Folder",10);