question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to find elements using XPath

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
ecchionicommented, Feb 12, 2020

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;

0reactions
hassanuzcommented, Oct 22, 2019

Hi @samkhayal, if you are still facing this issue, please open a new ticket.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webdriver Automation - Unable to find element using xpath
It's possible the page object has not loaded at the time Webdriver is searching for it. Try to locate the step that is...
Read more >
I can't find element using xpath [closed]
Using Chrome, open Developer Tools. · Select Elements tab · Locate web element using right-click, Inspect or use the arrow icon near the...
Read more >
Xpath Correct but still get no such element
My Xpath is correct & no iFrame and I can locate element in Chrome console but my program still fails. I have used...
Read more >
How to find element by XPath in Selenium with Example
This article will cover how to find Xpath in Chrome and how to utilize XPath to find web elements in automated Selenium testing....
Read more >
Unable to find the element located by 'By.xpath
I would like to have a wildcard to replace the 10 digits. I've tried: //[starts-with(@id,'PanelSubmitJobStream_1_StringJobStream_value')] // ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found