Sunday, November 21, 2010

ChildObjects - Frames,Dynamic Array

'http://localhost/sqlitemanager/
'Browser("WAMP5 Homepage").Page("WAMP5 Homepage").Link("phpinfo( )").Click @@ hightlight id_;_Browser("WAMP5 Homepage").Page("WAMP5 Homepage").Link("phpinfo( )")_;_script infofile_;_ZIP::ssf7.xml_;_
'Browser("WAMP5 Homepage").Page("WAMP5 Homepage").Link("SQLitemanager 1.2.0").Click @@ hightlight id_;_Browser("WAMP5 Homepage").Page("WAMP5 Homepage").Link("SQLitemanager 1.2.0")_;_script infofile_;_ZIP::ssf8.xml_;_
'Browser("WAMP5 Homepage").Page("SQLiteManager").Frame("main").WebCheckBox("uploadDB").Set "ON" @@ hightlight id_;_Browser("WAMP5 Homepage").Page("SQLiteManager").Frame("main").WebCheckBox("uploadDB")_;_script infofile_;_ZIP::ssf9.xml_;_
'Browser("WAMP5 Homepage").Page("SQLiteManager").Frame("main").WebCheckBox("uploadDB").Set "OFF" @@ hightlight id_;_Browser("WAMP5 Homepage").Page("SQLiteManager").Frame("main").WebCheckBox("uploadDB")_;_script infofile_;_ZIP::ssf10.xml_;_
'Dynamic Arrays
Dim dynamicArray()
Set oDesc = Description.Create
oDesc("micclass").Value = "Frame"
set cObj = Browser("WAMP5 Homepage").Page("SQLiteManager").ChildObjects(oDesc)
'msgbox cObj.Count
ReDim dynamicArray(cObj.Count)
' below for loop will convert  as below :
' from =  [ welcome ] link
'  to = welcome
For i=0 to cObj.Count -1
 childObjVal = cObj.item(i).ToString()  ' msgbox childObjVal
 startPos = Instr(1,childObjVal,"[")
 newVal = mid(childObjVal,startPos+1,len(childObjVal))
 endPos = instr(1,newVal,"]")
 endVal = mid(newVal,1,endPos-1)
    dynamicArray(i) = trim(endVal)  ' msgbox dynamicArray(i)
Next
'msgbox ubound(dynamicArray)
' below for loop is used click left side frames specific link
For j=0 to ubound(dynamicArray)-1
    strArray = dynamicArray(j)
If  strArray = "left" Then
    Set oDes = Description.Create
 oDes("micclass").Value = "Link"
 set childLinks = Browser("WAMP5 Homepage").Page("SQLiteManager").Frame(strArray).ChildObjects(oDes)  ' Browser("WAMP5 Homepage").Page("SQLiteManager").Frame("left").Link("Test").Click @@ hightlight id_;_Browser("WAMP5 Homepage").Page("SQLiteManager").Frame("main").WebCheckBox("uploadDB")_;_script infofile_;_ZIP::ssf9.xml_;_
     For k=0 to childLinks.Count -1
  childLinksVal = childLinks.item(k).ToString()    ' msgbox childLinksVal
  startPos = Instr(1,childLinksVal,"[")
  newVal = mid(childLinksVal,startPos+1,len(childLinksVal))
  endPos = instr(1,newVal,"]")
  endVal =  mid(newVal,1,endPos-1)   'dynamicArray(i) = trim(endVal)
  endVal = trim(endVal)
  msgbox trim(endVal)
  If endVal = "Test" Then
   Browser("WAMP5 Homepage").Page("SQLiteManager").Frame(strArray).Link(endVal).Click
   msgbox "Test is clicked"
  End If
 Next
End If
Next
' How to find co-ordinates of any text in the application
'l = 0
't = 0
'r = 0
'b = 0
'result = Window("Mozilla Firefox").WinObject("MozillaWindowClass").GetTextLocation("test123",l,t,r,b) @@ hightlight id_;_2164128_;_script infofile_;_ZIP::ssf1.xml_;_
'If result Then @@ hightlight id_;_460284_;_script infofile_;_ZIP::ssf2.xml_;_
' MsgBox "Text found. Coordinates:" & l & "," & t & "," & r & "," & b
'End If

' GetTOProperties example
'set objPro = Window("Mozilla Firefox").WinObject("MozillaWindowClass").GetTOProperties
'msgbox objPro.Count
'For i=0 to objPro.count-1
' 'msgbox objPro(i).Name
'If objPro(i).Name = "text" Then
' msgbox objPro(i).Name ' property name
'End If
'Next

No comments:

Post a Comment

 

©2010 Software Testing powered by Free Blogger Templates | Author : Anand Satish