How to get XPath in Script from Alias
How do I get the XPath from an Alias in a Python Script. So not the full path but ONLY the XPath that it is actually mapped to.
So not alias.Name wich would result in: "FindElement('xpath=//fro-input-wrapper[contains(@data-testid, \"FREQUENCY\")]//input')"
But only the XPath, so like: "//fro-input-wrapper[contains(@data-testid, \"FREQUENCY\")]//input"
Do you want to know which selector was used in a particular interaction? This is posted to the Log for each step.
Bear in mind also, the functionality of TestComplete NameMapping collects one-or-more XPath OR CSS selectors for an Alias, so it isn't a one-to-one property.
We only use the "data-testid" tag. So we only have one selector for every object that we map. But since TestComplete does apparently not support a good answer to the question I asked, I wrote my own script for that purpose. For anyone interested here it is.
def get_alias_xpath(alias): TimeoutValue = Options.Run.Timeout Options.Run.Timeout = 0 tmp = alias.Name xpath = tmp[13::] aliasxpath = xpath[:-2].replace("xpath=", "").replace('\"', '"') Options.Run.Timeout = TimeoutValue return aliasxpath