Locate elements with Java, XPath and ControlType
See original GitHub issueHey,
Is there a possibility to locate an element with XPath and the ControlType of an element?
When I try to locate an element with /*[contains(@Name,'WindowName')]
and use the method element.getAttribute("ControlType");
I’ll get the following output for the attribute:
{ProgrammaticName=ControlType.Window, Id=50032, LocalizedControlType=window}
.
How can I check for ControlType.Window
in my XPath query? The query
/*[contains(@ControlType,'ControlType.Window') and contains(@Name,'WindowName')]
seems not to work.
Issue Analytics
- State:
- Created 8 years ago
- Comments:31 (6 by maintainers)
Top Results From Across the Web
WinAppDriver - Locate element using text
The element has no properties other than Name , ControlType (which I am using in an XPath), and ValuePattern.Value which contains the ...
Read more >How to find element by XPath in Selenium with Example
Learn how to find Xpath in Chrome and locate elements using XPath in Selenium Webdriver with help of an example.
Read more >A practical Guide for Finding Elements with Selenium
That's right, Class Names are separated by spaces. Selenium does not have a validation for that, but Endtest does: 4) Find Element By...
Read more >desktop » Use UI Spy to help generate XPATH
“Find a component of any type ( /* ) that has an attribute called “ClassName” ( @ClassName ) with the value Notepad and...
Read more >javax.xml.xpath (Java Platform SE 8 )
An XPathFactory instance can be used to create XPath objects. ... In addition to element nodes, XPath location paths may also address attribute...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@heler12 , driver element usually represents root of your desktop, so searching for
/*
will search imidiate childrens of desktop only, i.e. open windows, not menu items inside those windows. Most likely you wanted following xpath//*[contains(@Name,'File')]
, note double slash, which means search in all descendants.But note that it will traverse a lot of elements in all open windows on your desktop which might make your test run very slow. It is recommended to first locate a window of interest and then use xpath starting from this window. So, you can use your old locator, but you will need to replace
driver
withmainWindow
, wheremainWindow
is element that correspond to notepad window that you found before.yes correct