WinAppDriver: Unable to find elements using XPath

Hi,

I’m trying to start with Windows automation. I have a problem with searching elements by xpath.

This is a part of source code of Calculator application on Windows image

When I try to find Window element by using this code, it works: driver.findElementByClassName("ApplicationFrameTitleBarWindow");

Similarly, I’m able to find this element by using

driver.findElementsByAccessibilityId("TitleBar")

When I try to use xpath expression driver.findElementByXPath("//Window[@className='ApplicationFrameTitleBarWindow']"); driver.findElementByXPath("//Window[@ClassName='ApplicationFrameTitleBarWindow']");

or

driver.findElementByXPath("//Window[@automationId='TitleBar']"); driver.findElementByXPath("//Window[@AutomationId='TitleBar']");

I received this error message org.openqa.selenium.NoSuchElementException: java.lang.ClassCastException: com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to java.lang.String (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: 'PC-ASUS', ip: '192.168.176.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77' Driver info: io.appium.java_client.windows.WindowsDriver Capabilities [{app=Microsoft.WindowsCalculator_8wekyb3d8bbwe!App, platformName=Windows, deviceName=PC-ASUS, platform=ANY}] Session ID: 1897e6af-b38b-4cea-8c58-b65e5b4beb61 *** Element info: {Using=xpath, value=//Window[@className='ApplicationFrameTitleBarWindow']} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180) at io.appium.java_client.windows.WindowsDriver.execute(WindowsDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:353) at io.appium.java_client.windows.WindowsDriver.findElement(WindowsDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:490) at io.appium.java_client.windows.WindowsDriver.findElementByXPath(WindowsDriver.java:1) at DemoWindows.main(DemoWindows.java:28)

I don’t know, where is the problem. XPath should work here. Can you please help?

Thank you.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (9 by maintainers)

Most upvoted comments

Why was this issue closed? Still having the same problem: Elements are not found by XPath. Windows 10, WinAppDriver 1.1, C#. WinAppDriver log: POST /session/CF6470EA-D3E7-47BC-9A84-3750DBF33411/elements HTTP/1.1 Accept: application/json, image/png Content-Length: 73 Content-Type: application/json;charset=utf-8 Host: 127.0.0.1:4723

{“using”:“xpath”,“value”:“.//Window[@AutomationId=‘uiFrmAccountUpload’]”} HTTP/1.1 200 OK Content-Length: 74 Content-Type: application/json

{“sessionId”:“CF6470EA-D3E7-47BC-9A84-3750DBF33411”,“status”:0,“value”:[]} Nothing is found, the test log returns the count of the collection as 0;