Micro Focus QTP (UFT) Forums
GetTOProperties count - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: GetTOProperties count (/Thread-GetTOProperties-count)

Pages: 1 2


GetTOProperties count - Steve.Govinakovi - 06-05-2012

Hi Guys,

I am working on windows forms. .Net 4 framework and QTP 10, I have installed the frameowrk before QTP10.

QTP is identifying the toolbar as a generic object (SwfObject:Toolbar) and not really a toolbar (SwfToolbar)

Object spy did not get the properties I was looking for, so I used ".Net Windows forms spy". I was able to see the properties of toolbar.

I got all the properties of toolbar using below code, but, count() fails with error Object required: 'val5.Count()'
(toolbar.properties.count(), as shown in below example)

1.
Code:
Set val5 = SwfWindow("Form").SwfObject("toolBar").GetTOProperties
Set a = val5.Count()
Reporter.ReportEvent micdone,"Test1",a
2.
Code:
Set val5 = SwfWindow("Form").SwfObject("toolBar").ChildObjects
Set b = val5.Count()
Reporter.ReportEvent micdone,"Test2",b
3.
Code:
Set val5 = SwfWindow("Form").SwfObject("toolBar").Object.Items
Set c = val5.Count()
Reporter.ReportEvent micdone,"Test3",c

ERROR:
Code:
Object required: 'val5.Count()'
Line (67): "Set a = val5.Count()".

4.
Below example worked
Code:
val = SwfWindow("Form").SwfObject("toolBar").GetROProperty("Enabled")
Reporter.ReportEvent micdone,"Test",val

5.
Code:
SwfWindow("Form").SwfObject("toolBar").GetROProperty("items(16)")
Above executes without error, but when execute below
Set val6 = SwfWindow("Form").SwfObject("toolBar").GetROProperty("items(16)")

ERROR: object required is thrown.


Can you please help me QTP to click an item "Insert Sample" in items(16) as shown in attachment

Also if possible, why is error thrown in example 5, when i add "Set"?

Thanks,
Steve
Update:

Code:
Set val5 = SwfWindow("Form").SwfObject("toolBar").GetTOProperties
a = val5.count
Reporter.ReportEvent micdone,"Test",a

Value for a is coming up as 1, which is incorrect, it has got more than one property.


RE: GetTOProperties count - Steve.Govinakovi - 06-05-2012

Update2: did remove Set from "a = val5.count" and executed below queries.
1
Code:
Set val5 = SwfWindow("Production Analyst").SwfObject("toolBar").GetTOProperties
a = val5.count
Reporter.ReportEvent micdone,"Test",a
2
Code:
Set val5 = SwfWindow("Production Analyst").SwfObject("toolBar").ChildObjects
b = val5.Count()
Reporter.ReportEvent micdone,"Test2",b
3
Code:
Set val5 = SwfWindow("Production Analyst").SwfObject("toolBar").Object.Items
c = val5.Count()
Reporter.ReportEvent micdone,"Test3",c

Following values were returned:
1. 1
2. 0
3. 20

That means I have to use 3rd option
Code:
Set val5 = SwfWindow("Production Analyst").SwfObject("toolBar").Object.Items

How will i get to explore all the values in val5?
Guys,

I Executed
Code:
Set val5 = SwfWindow("Production Analyst").SwfObject("toolBar").Object.Items
c = val5.Count()
Reporter.ReportEvent micdone,"Test3",c

Output = 20

As shown in attachment, window "Smat Item Collection Editor" has 20 item.
I am not sure, how to get to 16th item.

when i use
"Set s = val5(0).Item" or "val5(0)", I get the below error:
Object doesn't support this property or method: 'val5'

How do I access values in val5?


RE: GetTOProperties count - supputuri - 06-05-2012

Val5(0) will give you the value of first item in the object.
Code:
For i = 0 to Val5.Count
     msgbox Val5(i)
Next



RE: GetTOProperties count - Steve.Govinakovi - 06-06-2012

Thanks Supputuri.
When i execute below line error is thrown:
msgbox Val5(0)
ERROR:
Object doesn't support this property or method: 'val5'


RE: GetTOProperties count - supputuri - 06-06-2012

hey sorry,

there was a typo, we have to define the method which we want to retrieve.

eg.
Code:
msgbox Val5(0).GetROProperty("innertext")
     msgbox Val5(0).GetROProperty("Name")

Please let me know if you need any further information.


RE: GetTOProperties count - Steve.Govinakovi - 06-06-2012

Thanks mate, but it did not work.

I executed below code

Code:
Set Val5 = SwfWindow("Form").SwfObject("toolBar").Object.Items
c = Val5.Count()
Reporter.ReportEvent micdone,"Test3",c
msgbox Val5(0).GetROProperty("index")

Following error was thrown:
Object doesn't support this property or method: 'Val5'
Line (80): "msgbox Val5(0).GetROProperty("index")".

if i type Val5(0). -->QTP does not hint me with option.
if i type Val5. -->QTP gives me hint
so I typed Val5.Get --> QTP did not promt me with GetROProperty, options prompted by QTP is as shown in attachment.


RE: GetTOProperties count - Steve.Govinakovi - 06-07-2012

Can you please help me out. I have to get this working by tomorrow. Thanks Steve.


RE: GetTOProperties count - supputuri - 06-07-2012

HI Steve,

Sorry for the late replay.

The thing is it will not work because we don't have any run time property called "index". You can use GetROProperty() for only the run time properties.

I don't understand why you are pointing to the index number, help to understand your requirement clearly so that we can provide the answer.


RE: GetTOProperties count - Steve.Govinakovi - 06-08-2012

I do not like Analog recofing, so the question is, when is the good measure to take when you can not access the object or when you can not record using context sensitive mode.

Another option, when toolbar does not have "index" is to use Analog recording or low level recording and below is what was recorded when analog method was choosen
Code:
SwfWindow("FormName").SwfObject("toolBar").Click 559,20

What do you recommend?


RE: GetTOProperties count - Steve.Govinakovi - 06-10-2012

hi Supputuri,

I did not get any reply from you. I have used Mouse coridicates to locate the button and click particular button on toolbar, but if i run in different computer with bigger or small screen test will break. Do you have any recomendation, do you have any better way to handle this kind of tests?

I have run in to another problem, hope you will be able to help me out.
I have result displayed in grid and QTP is identifying the grid as a generic object (SwfObject:grid) and not really a toolbar (Swfgrid)
How can i get the value out of the grid --> rows --> cell and compare? Please find the first attachment, I would like to get the grid, I would like to get Time4 column, 2nd row, cell value and compare with expected result.

As shown in second attachment, Dot Net Spy shows properties of the row, but I can not find the values displayed in that row cell.

As shown in thrid attachment, I typed
Code:
SwfWindow("FormName").SwfObject("grid").Object.DataRows.
varous
options as displayed in screen shot is displayed.

when I use Test Complete, (another automaiton tool) obect spy of Test complete shows the Row values. Below is the code to access data row, cell values in Test Complete.
Code:
Aliases["System"]["FormName"]["Host"]["Browser"]["Base"]["Main"]["WinFormsObject"]("viewManager")["WinFormsObject"]("StandardView")["WinFormsObject"]("gridPanel")["WinFormsObject"]("grid")["DataRows"]["Item"](0)["Cells"]["Item"](0)
Below code is equal to SwfWindow("FormName").SwfObject("grid") code of QTP.
Code:
"Aliases["System"]["FormName"]["Host"]["Browser"]["Base"]["Main"]["WinFormsObject"]("viewManager")["WinFormsObject"]("StandardView")["WinFormsObject"]("gridPanel")["WinFormsObject"]("grid")"

and Datarows is common in QTP and Testcomplete.

Test complete recognizes it as ("grid")["DataRows"]["Item"](0)["Cells"]["Item"](0) but QTP does not.

In QTP I can access as shown in 3rd attachment:
Code:
SwfWindow("FormName").SwfObject("grid").Object.DataRows.item
But thows an error, when I type bracket in front of item, example below
Code:
SwfWindow("FormName").SwfObject("grid").Object.DataRows.item(0)
Error will be thrown.

Please help me, I am running out of time. Is it possible for you use team viewer to access my machine and help me or I request that any one of your team member to help me.