blatec
9 years agoOccasional Contributor
How can i find the Alias-Path to a Webelement
Hi
I want to search for a web element by his id or name and return the Alias - Path.
Can i realize this with a script?
something like:
var xxx = Aliases.frameMainwindow.Find("NativeWebObject.id", "*Gender", 500);
and get the Alias Path of xxx
regards
Horst
In the general case, you can have object names like Aliases.browser.page.Panel(0).Link("myLink"), where only a few parent objects have aliases. So the idea is to go up the chain of parent objects until you find the one with a non-empty MappedName, then combine it with the Name's of other objects. Something like this:
function Test() { Log.Message(GetAlias(Sys)); Log.Message(GetAlias(Sys.Process("explorer"))); Log.Message(GetAlias(Aliases.notepad.Window("#32770", "Font").Window("Button", "OK"))); } function GetAlias(obj) { if (obj.MappedName != "") return obj.MappedName; // object has its own alias if (obj.Parent == null) return obj.Name; // Sys and Mobile // Append the object name to the parent object's alias var alias = GetAlias(obj.Parent) + "." + obj.Name; return alias; }