Ask a Question

Accessing the controls on the web page

Bharadwaj
Contributor

Accessing the controls on the web page

Hi Guys,

I want to access controls on the web page. For example I have a developer express grid control on the web page which displays the user information. It has information as follows



Invoice #      Product   Total

1                     Car          100000

2                     Misc          1000



Now when the scan this page using test complete object explorer tool,I find its idStr attribute in the object browser as say paxtabs_vol_grid_invoce

Now coming to my main point of accessing this grid object, I am doing it in the following two ways : 



Approach 1 :  Use the object browser and scan the idString attribute and use it in my code to access the grid object. 



Approach 2 : Use the contents of the grid headers(in my case Invoice # or Product or Total),get the object in which they reside and then get the parent of that objct which in our case is the grid object and then access it the way I want.



Problem with Approach 1 :

The hard coded idString attriute in my Approach 1 keeps on changing whenever I upgrade my developers express. So every time I upgrade the developer express I have to rescan the grid and then get the new IdString attribute value of the grid and then replace it in my test scripts to work. This is hectic as it increases my maintenance.



Problem with Approach 2 : 

My grid header values or the data values in the grid  are not always consistent as the developers keep on changing them,so whene ever they change the header labels again I need to go to my code and update  it with the latest lable name to get the object in which it resides or else it wont find the old lable name any where on the page and my script will fail.



Can any one please suggest me a better approach where my maintenance will be minimum. Thanks in advance.



Regards,



Bharadwaj. 





1 REPLY 1
azakharov
Contributor

RE: Accessing the controls on the web page

Hi Bharadwaj,



In this case I would recomend to find out what part of the grid is not likely to be changed?

Normaly id is the best strategy. If it's dynamically generated, then is there a part of it that is constant? For example someIdString34287123. In this case "
someIdString' part is likely to stay constant.

If you can't rely on id then ask yourself what else you can use (contentText property of the child for example).

Even after that, there's no guarantee that you won't need to update your locators from time to time, so just do your best.

Hope it helps.
cancel
Showing results for 
Search instead for 
Did you mean: