Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Want to Automate clicking on Menu items
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi

I am Automating an ASP.Net application having teleric control with QTP 9.2. I am creating a generic keyword driven framework. I am able to successfully Login with my framework. Now i want to click on Menu items that i am able to do after that i want to click on menu items under it with same click function.I am able to do that if i pass only index of menu items but if i pass html tag and text as property it fails, as index is not a good option to work with, can anyone tell me what approach i should opt.


Just to tell, i have recorded click on menu item and run that it worked but when i use DP there for the object and taken text and html tag as property it failed.may with recording it is using other properties as well to identify the object.but it is hard to try with all combination of properties for many objects.

if there is any approach to click that by using DP then i can easily automate that in my framework.Can anyone help me to automate this issue.

You can assume the Menu items like this:

Name
.Ram
.Shayam
Age
.21
.25


Thankx
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
It's been my experience that the only reliable way to get DP to work with multiple criteria is to use a Description object array.

Code:
dim objdescription, myobj, linkarray
   set objdescription = Description.Create()
   objdescription("text").value = "Click Me"
   objdescription("html tag").value = "a"
   objdescription("html tag").RegularExpression = false
   objdescription("micclass").value = "Link"
   Set myobj = Browser("Browser").Page("Page")
   myobj.sync
   set linkarray = myobj.ChildObjects(objdescription)
   linkarray(0).Click

This should get you started. You can make it dynamic by passing in text and tag parameters. If there is more than one you can add other values to the array such as html id. I took this code a made a click function that will take my ID or Text parameter and search for any clickable object (link, button, image, etc) by changing the micclass if my linkarray object length is "0". You can also use regular expressions.
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks for that, but i used that approach only to click on objects and it is working fine for me for other objects but for some it is not working.

Please clarify few thing:

Scenario 1:
Before recording i set the Options in Object Identification window as Web--->Links----> Html tag, text, index and when i recorded that it recorded the value as: A,Add,none when i run that it clicked. but when i use DP with that parameters it failed. Then i thought to add more properties in O.R and clicked on add button i realized that value for other properties are already recorded by QTP although i have set only 3 parameters from Object identification window.

Is this possible that QTP is using combination from those properties as well to click on that object and i m using only html tag, text and index that is why it is failing. Please clear this.


Scenario 2:
When i set only ordinal identifier in object identification window for web--> link and recorded the click event on that object then it showed me its index value as 6 and no other property as i have set only index option in object identification.

and when i done DP only with index value it clicked. but when i used index value with other properties like text in DP it failed again.


I have taken Text,Html Tag, index as properties for all links and i want it to be consistent otherwise i have to take some properties for one link and others for other links.Objects for which it showed None after spying as ordinal identifier i used index as 0 for those.Please help me.

Just to know is there any way by which At run time i can verify the object below and object after, the object under test so that always right object is identified at run time.

Thanx
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
I'll try to clarify.

First using DP ignores the OR, but I'm sure you knew that.

When using DP, you must be very specific in your object to get only one object. You might try using HTML ID instead of Text. If you have a dozen links on a page that all have the text of "Edit", they will all be returned in the child objects and you can use the index key to get the one you want.
Code:
linkarray(0).Click

That is what this did. You can change the "0" to the index option you need. When you use a .NET Grid or List object that is the only way to click the correct link in the data. There are ways to search the table for the row you need, provided there is a unique key or data, then use that as the array index as well.

In my click framework, I pass the index with a default of "0" so at the very least it will click the first object in the array.

Be sure you are setting your micclass. Also, try using Regular expressions to search for the text of the link. That might help narrow down the objects array so you won't have to deal with the indexing.

I hope this helps.
I don't think I explained that very well, so I decided to share my framework. I'm sure there is a lot of room for improvement but it suits my needs and makes it very simple for my team to reuse the code.

There are some page/browser variables you need to set at the top of the code to work with the website you are working with. After that it the framework should work fine. I generally include another library setting those values, but for this upload it's all one file.

Documentation is always a work in progress for me, so I apologize if it's a little lax in some areas.

I hope you find this useful.


Attached Files
.txt   webframework.txt (Size: 24.41 KB / Downloads: 136)
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks for that, i resolved that issue in my click function as i am taking text property and in that i have done one silly mistake i have not make regular expression false, and the text property is having special symbol in it, due to which it was failing.

Yesterday i automated Ajax for my application, and i am very much successful in that but at one case there is a problem as, while the ajax is going on a pop up appears, now qtp is in ajax function waiting to complete but it will not set its status as complete until i pop up is clicked. What i thought is to use timer as well in condition that if the status is not complete then it should wait for that particular seconds in ajax function.

Don't you think with this my scripts will fail if application responds slowly as ajax will not be complete within that time limit.Is there any other best possible approach for that.

I will go through your code today and tree to use the approach where i require. Thanks for helping me.

I am facing one more issue with my Function named verifytextonpage in that i am taking all child objects on page and then i iterate all child objects innertext property to find my string with help of INSTR function but the problem is that the function is slow as it has to iterate no. of times to find the string. Is there is any other way to to that.

I appreciate your help, Thanks once again!
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
In my framework, I have a search page for text function that uses the page innertext and a INSTR function. It doesn't really care about objects, just text and is a lot faster than the childobject method. It might suit your needs.

AJAX can be tough because the html objects don't exist until later. Try doing a page.sync then a search and click on the object you need. That might work. I know in QTP10 there is a new dev application called the Web Extensibility that is suppose to be able to test ajax, but I haven't used it much and it probably won't work well with 9.2. Best bet is going to be the sync then click. It depends on how the popup is coded. If it's a hidden div that just becomes visible, QTP can find it. If it's a javascript function that builds and adds HTML it might be more difficult, but I still think QTP will find it if you use the right object. Try my click framework, see if it works.
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
I Automated Ajax in my framework, i have seen the text search in your file and that worked for me. Thankx for it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to fetch items from WpfList in UFT saurabhkumar_gupta 0 2,451 03-08-2015, 09:17 PM
Last Post: saurabhkumar_gupta
  Can't locate items on Win7 Desktop RandomGrin 0 2,072 01-30-2015, 10:55 PM
Last Post: RandomGrin
  QTP not clicking on the flex button sudheerch 2 3,624 12-03-2013, 12:56 PM
Last Post: sudheerch
  Clicking command button in accesss form mark_cielos24@yahoo.com 1 3,356 05-07-2013, 10:52 PM
Last Post: agarwl.anurag
  Problem in selecting multiple items in the weblist vijay44 7 18,268 08-10-2011, 06:22 PM
Last Post: gaveyom

Forum Jump:


Users browsing this thread: 2 Guest(s)