Forum Discussion
9 Replies
Hi Vallalarasu,
As Colin suggested, you can use the FindChild or Find method. For example:
Sub Test
' Searches for the control
Set p = Panel("calendarWrapper").Panel(0).Panel(0).Panel("calendarDouble").Panel(1)._
Panel(0).Panel(2).Table(0).Cell(0, 2).Panel("calendarMatrix")
Set control = p.Find("Contenttext", "<YourText>", 1000)
End Sub
- Colin_McCraeCommunity HeroNot enough info.
For a start - what language?
Second, what are the child objects? You appear to be extracting the text of the entire calendar. Are there child objects for the individual days? FindChild on the calendar object using the date required (content text) would seem like the easiest way to do it. IF there are such child objects.
If you want the script written for you, you'll need to provide more info .... - Vallalarasu_PFrequent Contributor1) Need for VBScript
2) The Content Text property if I use, I will be able to select the dates from 1 to 30
3) I have to do data driven with that
Plz let me know if you need more info - Vallalarasu_PFrequent ContributorThanks for that reply. I have used the method you have specified.
After finding the object i have to click it. Hence I wrote a code as
Control.Click
(It click the calender of the corresponding text value which we have found using the control
Problem is I'm getting object does not exist. The actual code im using i have posted below.
sub T1()
Browsers.Item("iexplore").Run("http://website.com")
set FromCity = NameMapping.Sys.browser.HPage
set control = FromCity.Find("ContentText","11",1000)
control.Click
End Sub.
Please let me know the solution.
Hi Vallalarasu,
First of all, I recommend that you use the Exists property to check whether the object exists before clicking it:
Sub T1()
Browsers.Item("iexplore").Run("http://website.com")
set FromCity = NameMapping.Sys.browser.HPage
set control = FromCity.Find("ContentText","11",1000)
If control.Exitsts Then
control.Click
Else
Log.Message("The object wasn't found")
End If
End Sub
One more note: you are searching for an object on the entire page. In this case, TestComplete is iterating through all objects unless the needed one is found. It can take some time and speed down the test execution. You need to call the Find method from one of the nearest parent of the needed object.
- Colin_McCraeCommunity HeroAlso, have you checked what type of object (if any) that FindChild is returning?
Ideally, I would use more than just the content text as the search criteria. ClassName or something so it actually returns the correct object. If you just search for "11", it'll find anything that matches so you may be getting labels back or who knows what.
I would be wrapping all this stuff in error checks and recovery handling. Automated tests need to be robust. They're no use if the slightest problem causes the whole thing to crash ... - Vallalarasu_PFrequent ContributorThe object exists, its unique too... But sill i get object required error. Please check with the complete code given below.
Please suggest me if you have any other simpler method to do the same operation
Sub Test1
Call Browsers.Item(btIExplorer).Navigate("http://www.lufthansa.com/online/portal/lh/in/homepage")
Aliases.browser.HPage.Pane.form.Panel.panelClW50.OneWay.Click
Call Aliases.browser.HPage.Pane.form.textboxNs7Co19vhuc6nkl80aieuv2f9.SetText("del")
Call Aliases.browser.HPage.Pane.form.Tobox.SetText("fra")
Call Aliases.browser.HPage.Pane.form.panelSubtpl.panelCl.textboxNs7Co19vhuc6nkl80aieuv2f9.Click
set calObj=Sys.Browser("iexplore").Page("http://www.lufthansa.com/online/portal/lh/in/homepage").Panel("ns_7_CO19VHUC6NKL80AIEUV2F91IH5_fmOutboundDateDisplay_dropdown").Panel("calendarWrapper").Panel(0).Panel(0).Panel("calendarDouble").Panel(1).Panel(0).Panel(2).Table(0).Cell(0, 2).Panel("calendarMatrix").Table(0)
PropArray = Array("Name", "contenttext")
ValuesArray = Array("TextNode(0)", "22")
datelist=calObj.findAll("PropArray","ValuesArray",10,true)
Log.Message("Count :" & UBound(datelist))
for each dt in datelist
Log.Message(dt.contenttext)
dt.Click
next
End Sub - Vallalarasu_PFrequent ContributorI found the solution for this and its paste below.
Sub Test1
Call Browsers.Item(btIExplorer).Navigate("http://www.lufthansa.com/online/portal/lh/in/homepage")
Aliases.browser.HPage.Pane.form.Panel.panelClW50.OneWay.Click
Call Aliases.browser.HPage.Pane.form.panelSubtpl.panelCl.textboxNs7Co19vhuc6nkl80aieuv2f9.Click
dim datelist
set calObj=Sys.Browser("iexplore").Page("http://www.lufthansa.com/online/portal/lh/in/homepage").Panel("ns_7_CO19VHUC6NKL80AIEUV2F91IH5_fmOutboundDateDisplay_dropdown").Panel("calendarWrapper").Panel(0).Panel(0).Panel("calendarDouble").Panel(1).Panel(0).Panel(2).Table(0).Cell(0, 2).Panel("calendarMatrix").Table(0)
PropArray = Array("contenttext")
ValuesArray = Array("22")
datelist=calObj.findAll(PropArray,ValuesArray,10,true)
Log.Message("Count :" & UBound(datelist))
for each dt in datelist
Log.Message(dt.contenttext)
dt.Click
next
Call Aliases.browser.HPage.Pane.form.panelBtnwrapper.textnodeSearchFlights.Click
End Sub
I have a doubt..only FINDALL works why not FIND,FINDCHILD or FINDALLCHILDREN??????????? - Waiting for your valuable response
Thanks in advance