| || |
Weblist Identified as WebElement.
We have automated our application where in a single page we have multiple weblists ,recently our application got upgraded to new version and these weblists are identified as WebElement but to identify we need to depend on Index no in that web element where the Index No is dynamic so can any one suggest any other way where we can Automated that WebELements are identified.
Tried finding the child objects of the total web page but it was showing me around 2000 Web Elements so how to click on a particular webelement i want to know.
First thing you should do when something like this happens is talk to development. Show them what changed and what identifiers you can possibly use. See if they can provide you with one.
If they can't or won't help with putting a more reliable identification mechanism in place, here's something you can try:
My friend Arun was dealing with something similar and turned it over to me to find an answer to his question. Here's how I investigated his problem.
His problem was similar, in that all he spied on was coming back as WebElements. Upon ruling out tool error, I created a collection for all like child objects on the page and reviewed the count, which turned out to be very high when considering the relative handful of visible fields on the page. All that was displayed were four or five edit boxes and what appeared to be a list, and in doing this, realized that the list items were actually web elements themselves.
From there, it wasn't much of a stretch to write some code to highlight each item of the collection. I also had its item number, html tag, and innertext printed to the output window so that I would know the item number for later, if needed.
With a little more refinement, I had identified all the items for the list. It took the addition of an extra property, that being class, to clearly identify the entire list. Once there, we were home free and able to work through the issue.
I was wondering... has anyone tried using the Extensibility Accelerator for this sort of problem. I've been wanting to, but haven't really had the time to mess with it. Does it work for this sort of thing?
Want code? I don't mind sharing; here it is. Keep in mind that it's not bulletproof; the point is to demonstrate the investigative process.
strTargetLink = "Work"
'Part I: build a collection of web elements to determine how many elements exist on the page and what exactly the target element looks like.
' This is for exploratory purposes only, although you could easily leverage it for other purposes, if needed.
Set objWebElementListItems = Description.Create
objWebElementListItems("micclass").Value = "WebElement"
objWebElementListItems("class").Value = "active-result.*"
objWebElementListItems("html tag").Value = "LI"
'Above properties were arrived at via process of elimination. Plus, if you hold the ctrl key down when using object spy, you can spy
' on objects that appear as the result of selection of other objects.
' As it turns out, the list items are recognized as web elements.
Set colWebElementListItems = Browser("Panera Web Ordering Applicatio").Page("Panera Web Ordering Applicatio").ChildObjects(objWebElementListItems)
For i = 0 To colWebElementListItems.Count - 1 Step 1
print(colWebElementListItems(i).GetROPRoperty("htm l id"))
Set colWebElementListItems = Nothing
Set objWebElementListItems = Nothing
'Part II: now that we know what the target object(s) look like, we can take action against them.
With Browser("Panera Web Ordering Applicatio").Page("Panera Web Ordering Applicatio")
Select Case strTargetLink
.WebElement("html tag:=LI", "class:=active-result.*", "innertext:=Work").Click
.WebElement("html tag:=LI", "class:=active-result.*", "innertext:=Home").Click
.WebElement("html tag:=LI", "class:=active-result.*", "innertext:=Apartment").Click
.WebElement("html tag:=LI", "class:=active-result.*", "innertext:=Dormitory").Click
.WebElement("html tag:=LI", "class:=active-result.*", "innertext:=Other").Click
.WebElement("html tag:=LI", "class:=active-result.*", "innertext:=-Select-").Click