sirping
3 years agoOccasional Contributor
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"
mikef 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