Forum Discussion

venkatesh26's avatar
14 years ago

Object dosen't support this property or method when using string manipulations

hi, i got a problem.Please anybody help.

i am having a function like



function imagesearch()

{

  var PropArray, ValuesArray, ConPropArray, ConValuesArray, p, w,second,i,prop1,value1,q;

  PropArray = new Array("alt");

  ValuesArray = new Array("Collapse R");

  ConPropArray = ConvertJScriptArray(PropArray);

  ConValuesArray = ConvertJScriptArray(ValuesArray);

  p = Sys["Process"]("iexplore")["Page"]----------------------------------------------------["Link"](0);

  w = p["FindChild"](ConPropArray, ConValuesArray, 10);

  if (w["Exists"])

  {

    for(i=0;i<7;i++)

    {

      //second=Sys["Process"]("iexplore")["Page"]----------------------------------["Table"](i)["Cell"](0, 1)["Link"](0);

      Prop1 = new Array("alt");

      Value1 = new Array("Expand IL");

      ConPropArray = ConvertJScriptArray(Prop1);

      ConValuesArray = ConvertJScriptArray(Value1);

      q=second["FindChild"](ConPropArray, ConValuesArray, 10);

      if(q["Exists"])

       {

        q["Click"]();

        break;

       }

    }

  }

  else

  {

    ShowMessage("U did mistake somewhere");

  }

}

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 above code is working perfectly but now i need to convert the p to string and split and do some string manipulations and click the first child and below is the code for it.



function test()

{

var strA, strB, strC,q,i,stringtwo; 


strA = "Sys[\"Process\"](\"iexplore\")[\"Page\"](\"http-----------------------\")[\"Form\"](\"aspnetForm\")[\"Panel\"](2)[\"Table\"](\"ctl00_ContentPlaceHolder1_Wizard1\")[\"Cell\"](0, 0)[\"Table\"](2)[\"Cell\"](0, 1)[\"Panel\"](\"div1\")[\"Table\"](0)[\"Cell\"](0, 1)[\"Panel\"](\"ctl00_ContentPlaceHolder1_Wizard1_TreeView1\")[\"Table\"](0)[\"Cell\"](0, 0)[\"Link\"](0)[\"Image\"]";

strC=aqString["ListSeparator"];

aqString["ListSeparator"]="[\"Table\"]";

var stringone="[\"Table\"]";

var stringthree="[\"Panel\"](\"ctl00_ContentPlaceHolder1_Wizard1_TreeView1n0Nodes\")";

var stringfour="(i)[\"Cell\"](0, 1)[\"Link\"](0)";

stringtwo=aqString["GetListItem"](strA,0)+ stringone+aqString["GetListItem"](strA,1)+stringone+aqString["GetListItem"](strA,2)+stringone+aqString["GetListItem"](strA,3)+stringthree+stringone+stringfour;

 for(i=0;i<7;i++)

    {

      stringtwo=aqString["GetListItem"](strA,0)+stringone+aqString["GetListItem"](strA,1)+stringone+aqString["GetListItem"]  

                          (strA,2)+stringone+aqString["GetListItem"](strA,3)+stringthree+stringone+stringfour; 

      var realstring;

      var Prop1, Value1;

      var ConPropArray, ConValuesArray;

      Prop1 = new Array("alt");

      Value1 = new Array("Expand IL");

      ConPropArray = ConvertJScriptArray(Prop1);

      ConValuesArray = ConvertJScriptArray(Value1);

      q=stringtwo["FindChild"](ConPropArray, ConValuesArray, 10);

      if(q["Exists"])

       {

         q["Click"]();

         break;

       }

    }

 }




now the line which was in bold was showing error stating "Object dosen't support this property or method ".




1 Reply

  • Hi,



    Strings shouldn't support methods which belong to other objects. Use JScript's eval function to obtain the corresponding object by a string (obj = eval(str)).