Forum Discussion

sirping's avatar
sirping
Occasional Contributor
2 years ago
Solved

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-inp...
  • sirping's avatar
    sirping
    2 years ago

    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