Forum Discussion
I'm assuming you're not using NameMapping to identify your objects? The reason I say that is that using NameMapping you can identify the panels by other things (like className, Caption, etc) rather than just the object identifier which won't be subject to the variability that you're noticing.
Or, you could incorporate "FindChild" methodology in your automation so that, rather than using the long string, you'd do something like
var page = Sys.Browser("chrome").Page("*") var form = page.Form("*") var firstPanel = form.FindChild(['ObjectType','className'], ['Panel', 'TitleDiv'], 1) var secondPanel = firstPanel.FindChild(['ObjectType','className'],['Panel','HeaderDiv'], 1)
As far as I know, the Panel identifiers you can't (and shouldn't) wildcard since that could confuse a number of things. I'd strongly recommend "FindChild" for your object identification if you're not going to use NameMapping. Those you can more easily wildcard or build out better identification logic.
- Mathit7 years agoContributor
Thank you.
- Mathit7 years agoContributor
set page1 = Sys.Browser("chrome").Page("*").Panel(0).Panel(0).Panel(0).Section("content").Panel(1).Panel("applicantForm").Panel(0).Form("ttt").Panel(0).Panel(0).Panel(7).Panel(0).Panel(0)
panelobj = page1.Child(0).Name
set page2 = page1.panelobjIm using like the above to find the Panel name. Here panelobj returns the correct name of the object.
But page2 always returned as Non-existent object. Is there a reason for this?
- tristaanogre7 years agoEsteemed Contributor
Yes, the reason being is that there is no such thing as page1.panelobj. panelobj is just a string. If you want, specifically, the object you can just have
set page1 = Sys.Browser("chrome").Page("*").Panel(0).Panel(0).Panel(0).Section("content").Panel(1).Panel("applicantForm").Panel(0).Form("ttt").Panel(0).Panel(0).Panel(7).Panel(0).Panel(0) panelobj = page1.Child(0)
Now panelObj is whatever Child(0) is.
However... this is not necessarily going to always return the same object if Child(0) ends up being something different sometime. Even if you went ahead with grabbing the name, again, that's no guarentee. The better solution, as mentioned, is either to map your objects using ObjectType coupled with something static like caption, value, idStr, etc. I use className for a lot of my mappings.
If you don't want to use NameMapping, then FindChild is your next bet... and that also uses the same type of criteria of finding an object based upon a set of properties. Either of these two methods are "best practice" when attempting to find or identify an object.
Related Content
Recent Discussions
- 18 minutes agoSvetaG