Welcome, Guest. Please login or register.
Login with username, password and session length

 
Advanced search

18120 Posts in 4741 Topics- by 31743 Members - Latest Member: suuraj
 

Pages: [1]   Go Down
Print
0 Members and 1 Guest are viewing this topic.
Author Topic: Collection of JavaStaticText    (Read 1447 times)
gurvinder dhillon
FRProject
User
*
Offline Offline

Posts: 15

Software Professional


« on: August 27, 2008, 11:46:40 PM »

Hi,
I have a JavaFrame having multiple JavaStaticText's.
It displays like this:
Name Test123
Address Add123
Phone 12345

Name name2
Pref abc

All these are statictext objects. The screen has two objects with label Name. How do i identitify them. Index's are dynamic because if the phone number is blank the index would change.
So basically my problem is because of the dynamic index number.

I am trying the below:
Set Desc = Description.Create()  'Build a Description object
Desc("to_class").Value = "JavaStaticText"  'Set some selective properties

Set statictxt = javawindow("jwindow").JavaInternalFrame("JFrame").ChildObject(Desc)  'Collect all enabled child objects of type jstatictext
msgbox statictxt.count()
name = statictxt(13).GetROProperty("attached text")

How do i handle this.

Thanks,
Gurvinder
Logged
Meir Bar-Tal
Administrator
Advanced User
*****
Offline Offline

Posts: 1283



WWW
« Reply #1 on: November 09, 2008, 12:27:08 AM »

I apologize for the time it has taken to answer this question.
We must have somehow missed it.

Now, To the point.

Well, I've had experience with such identification problems (in a Web application, though, but it's the same trick).

The problem stems from the fact that the developers don't provide a unique id for each object; in Web it would be a nsme or html id, in Java it woukd be a tag (or attached text, or whatever). The problem you're describing with the indexes is a genuine one.

Now to the good news.

I solve such problems thinking out of the box. My assumption is that in such a case we need to imagine how a human user would perform the task (after all, he/she doesn't know the object id, even if it exists). So, you need to think about the static text beside the JavaEdit as if it were attached text. That is, it's an object that appears on the left side of the required JavaEdit. What I do in such a case? I get two collections of objects (similar to what you've suggested) one for the statics and one for the JavaEdits. Then I loop through the static collection, and check for the text of each object. If it fits the label I'm looking for, then I take the X/Y coordinates and width, and look for another JavaEdit in the other collection that is at about the same height (Y coordinate) and to the right of the static (X+Width).

This way I can identify the objects dynamically, as if a human eye would scan the screen and spot the label to lead the hand to move the mouse to the field just next to the right.

I hope this is clear. If you'd need more help, don't hesitate to apply.
Logged

Best Regards,

Meir Bar-Tal
AdvancedQTP Chief Editor & Forums Administrator
gurvinder dhillon
FRProject
User
*
Offline Offline

Posts: 15

Software Professional


« Reply #2 on: November 10, 2008, 01:19:45 AM »

Hi,
Thanks for your reply.
I will try using the same as mentioned by you.

Regards,
Gurvinder
Logged
kuldeep tyagi
FRProject
User
*
Offline Offline

Posts: 8

I want to rock in automation field.


« Reply #3 on: February 08, 2010, 02:54:03 AM »

Hi meir,
I did the way you describe see the below code.

set obj=description.Create
 obj("class description").Value = "static_text"
set objt=JavaDialog("Login").ChildObjects(obj)For i=0 to objt.count-1
If trim(objt(i).getroproperty("label"))="New Password:" then
width=objt(i).getroproperty("width")
x=objt(i).getroproperty("x")
y=objt(i).getroproperty("y")
end if
Next

set obje=description.Create
 obje("class description").Value = "edit"
obje("y").value=y

Set objedi=JavaDialog("Login").childobjects(obje)
For j=0 to objedi.count-1
objedi(j).set "kuldeep"
Next


This is working fine if theer is only one edit box at the same heaight (y).How we will do teh code ifthere is more than 1 edit box at the same height. I mean

label1 editbox1 labe2 editbox2 label3 editbox3 (these all label and edit are in sam e row)
Logged
Meir Bar-Tal
Administrator
Advanced User
*****
Offline Offline

Posts: 1283



WWW
« Reply #4 on: February 08, 2010, 05:40:41 AM »

The answer is simple: you're looking for the field on the right of the label just next to it, so you're looking for objedi(j) where :
objedi(j).Object.y is within a reasonable range around y and y+height (up to some accuracy degree) and
x < objedi(j).Object.x < objedi(j+1).Object.x < objedi(j+2).Object.x < ... < objedi(objedi.count-1).Object.x

I hope this helps.
Logged

Best Regards,

Meir Bar-Tal
AdvancedQTP Chief Editor & Forums Administrator
Pages: [1]   Go Up
Print
Jump to: