Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Mihai_Eminescu Super Contributor.
Super Contributor.
2926 views

Child items in WebTable

Jump to solution

Hy guys,

Hopefully some of you encountered this odd behaviour and maybe could shed some light on me cause I haven't managed to figure it out. I'm using UFT 12.02 to automate a BPM platform from Appian on Chrome browser.

I'm trying to select/set values for 3 WebList and 2 WebEdit objects that are inside a WebTable. The WebTable has a button that allows me to add new rows. After I click the button i wait for the existance of a certain element in the WebTable that assures me that the new row is created.

The code used for this is pretty much the one bellow : 

 

Set br = Browser("micClass:=Browser").Page("micClass:=Page")

br.webbutton("name:=ADD NEW ROW").Click ' wait for object existance function is used here
Set wt = br.webtable("innertext:=Some relevant text.*") rows = wt.GetROProperty("rows") wt.ChildItem(rows,1,"weblist",0).select value_1 wt.ChildItem(rows,2,"webedit",0).set value_2 wt.ChildItem(rows,3,"webedit",0).set value_3 wt.ChildItem(rows,4,"weblist",0).select value_4 wt.ChildItem(rows,5,"weblist",0).select value_5

When I run this code i receive an "Object required: 'wt.ChildItem(...)'" error for the last WebList most of the time (1 out of ~5 times it runs smoothly). 

After each value is set there is some loading done on the page so i've decided to use the wait property to see what happens. So, after the first WebList's value was set the script waited for 2 seconds and then returned the same "Object required" error for the first WebEdit (the second object in the list). I've used the .ChildItemCount method to see what it returns in this case and sure enough it was '0'.

wt.ChildItem(rows,1,"weblist",0).select value_1
wait 2
print wt.ChildItemCount(rows,2,"webedit")
wt.ChildItem(rows,2,"webedit",0).set value_2

So ... I'm not really sure what's going on here. If the values are set 'fast enough' it works fine, but if there are some delays the WebTable's elements somehow lose their identification properties ?!?

Any ideas ? 

 

Thanks in advance.

 

 

Accept as solution and give kudos to the author if the information helped you solve your problem.
0 Likes
1 Solution

Accepted Solutions
Mihai_Eminescu Super Contributor.
Super Contributor.

Re: Child items in WebTable

Jump to solution

I've finally managed to get it to work properly. To do so, I've created object references to some variables and used those variables instead when setting the values. The initial code now looks like this :

Set br = Browser("micClass:=Browser").Page("micClass:=Page")

br.webbutton("name:=ADD NEW ROW").Click
' wait for object existance function is used here

Set wt = br.webtable("innertext:=Some relevant text.*")
rows = wt.GetROProperty("rows")

Set child_1 = wt.ChildItem(rows,1,"weblist",0)
Set child_2 = wt.ChildItem(rows,2,"webedit",0)
Set child_3 = wt.ChildItem(rows,3,"webedit",0)
Set child_4 = wt.ChildItem(rows,4,"weblist",0)
Set child_5 = wt.ChildItem(rows,5,"weblist",0)
child_1.select value_1
child_2.set value_2
child_3.set value_3
child_4.select value_4
child_5.select value_5
Accept as solution and give kudos to the author if the information helped you solve your problem.
0 Likes
3 Replies
Mihai_Eminescu Super Contributor.
Super Contributor.

Re: Child items in WebTable

Jump to solution

I've finally managed to get it to work properly. To do so, I've created object references to some variables and used those variables instead when setting the values. The initial code now looks like this :

Set br = Browser("micClass:=Browser").Page("micClass:=Page")

br.webbutton("name:=ADD NEW ROW").Click
' wait for object existance function is used here

Set wt = br.webtable("innertext:=Some relevant text.*")
rows = wt.GetROProperty("rows")

Set child_1 = wt.ChildItem(rows,1,"weblist",0)
Set child_2 = wt.ChildItem(rows,2,"webedit",0)
Set child_3 = wt.ChildItem(rows,3,"webedit",0)
Set child_4 = wt.ChildItem(rows,4,"weblist",0)
Set child_5 = wt.ChildItem(rows,5,"weblist",0)
child_1.select value_1
child_2.set value_2
child_3.set value_3
child_4.select value_4
child_5.select value_5
Accept as solution and give kudos to the author if the information helped you solve your problem.
0 Likes
RohitS1 Absent Member.
Absent Member.

Re: Child items in WebTable

Jump to solution

Hi Mihai,

I got the problem you are facing.

After clicking on button to add row, you can synchronize the page by using "br.sync" or if sync is not working put wait as per application's processing time. After page synced you need to use "wt.RefreshObject"

Hopefully 'RefreshObject' will solve your problem. your code should loolike below.

Set br = Browser("micClass:=Browser").Page("micClass:=Page"​)

br.webbutton("name:=ADD NEW ROW").Click
' wait for object existance function is used here

Set wt = br.webtable("innertext:=Some relevant text.*")
wt.RefreshObject
rows = wt.GetROProperty("rows")

wt.ChildItem(rows,1,"weblist",0).select value_1
wt.ChildItem(rows,2,"webedit",0).set value_2
wt.ChildItem(rows,3,"webedit",0).set value_3
wt.ChildItem(rows,4,"weblist",0).select value_4
wt.ChildItem(rows,5,"weblist",0).select value_5

0 Likes
Mihai_Eminescu Super Contributor.
Super Contributor.

Re: Child items in WebTable

Jump to solution

Hi Rohit,

 

Thanks a lot for the response.

I've already tried to use 'RefreshObject' but that didn't work in my case, and the .Sync method doesn't seem to do anything (neither on the browser object or the page object).

Thankfully the workaround provided in the previous post works like a charm.

Accept as solution and give kudos to the author if the information helped you solve your problem.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.