Answer the question
In order to leave comments, you need to log in
Is it possible to find the absolute XPath path of desktop application elements?
Good day to all readers!
At work, I was given the task of automating the GUI of a desktop application (I don’t give the name, based on non-disclosure conditions) and immediately ran into the problem of finding the absolute XPath path to the application elements. For automation, I chose the Winium.Cruciatus framework.
Here is an XPath with a relative path where I find the element I need:
var TextBoxElement = win.FindElement(By.XPath(".//*[@ClassName = 'PasswordBox' and contains(@LocalizedControlType, 'field')]") );
Here is an XPath with an absolute path that I tried to write, but it did not work and the TextBoxElement variable was set to null, I looked for this path through WInAppUiRecorder:
var TextBoxElement = win.FindElement(By.XPath("/Pane[@Name=\"Desktop\"][@ClassName=\"#32769\"]/Window[@Name=\"Application Name\"][ @ClassName=\"Window\"]/Tab[@ClassName=\"TabControl\"]/TabItem[@Name=\"Connection\"][@ClassName=\"TabItem\"]/Custom[@Classname=\ "CredentialBoxControl\"]/Edit=\"PasswordBox\"]"));
OS: Windows 7.
Development environment: Visual Studio 2015.
I am attaching a screenshot of the DOM tree in Inspect, through which I am looking for an element:
Please help me with solving the problem. Searching for an element in a relative path takes a very long time.
Answer the question
In order to leave comments, you need to log in
Thank you for your attention! I settled on the decision to prescribe an absolute / relative path, for example: *
[@ClassName = 'Window' and @Name = 'Быстрый поиск услуг']/*[@ClassName = 'TextBox' and @LocalizedControoType = 'поле']
etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question