Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find Element By XPATH is not working on MS Word using AppiumForMac #86

Open
AryaKrishnan08 opened this issue May 4, 2020 · 6 comments

Comments

@AryaKrishnan08
Copy link

Hi, I am getting "No such element" error with findElementByXpath for Word app.

I have used absolute xpath generated by AFM:
driver.findElementByXPath("/AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXButton[@AXTitle='Create' and @AXIdentifier='_NS:73']").click();

xpath is working fine for other apps like calculator and Notes app.
This issue is only with Word and other O365 apps.

Mac OS : Mojave
AFM Beta 3

Can anyone help me on this. Thanks in advance.

Appium logs:
[Appium4Mac] [STDERR] ************* findAllUsingAbsoluteAXPath: /AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXButton[@AXTitle='Create' and @AXIdentifier='_NS:73']
[Appium4Mac] [STDERR] 2020-05-04 18:12:26.661 AppiumForMac[7620:212337] axPathComponents:(
[Appium4Mac] [STDERR] "AXApplication[@AXTitle='Word']",
[Appium4Mac] [STDERR] "AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']",
[Appium4Mac] [STDERR] "AXButton[@AXTitle='Create' and @AXIdentifier='_NS:73']"
[Appium4Mac] [STDERR] )
[Appium4Mac] [STDERR] 2020-05-04 18:12:26.676 AppiumForMac[7620:212337]
[Appium4Mac] [STDERR] ************* findAllUsingAbsoluteAXPath matchedNodes:(
[Appium4Mac] [STDERR] )
[Appium4Mac] [STDERR]
[Appium4Mac] [STDERR]
[WD Proxy] Got response with status 200: {"status":7,"sessionId":"PLvdlCm2","value":{"message":"An element could not be located on the page using the given search parameters."}}
[WD Proxy] The response has an unknown format
[W3C (27549f78)] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: The request to /wd/hub/session/27549f78-1868-4a49-8a41-b98f2044630d/element has failed
[W3C (27549f78)] at JWProxy.proxy (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:213:13)
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[HTTP] <-- POST /wd/hub/session/27549f78-1868-4a49-8a41-b98f2044630d/element 404 5010 ms - 771

@miksch123
Copy link

Have you tried it using a webdriver wait?
I ran into a similar issue and adding a wbdriverwaiter to wait for the element to appear actually helped there. (And yes there might be the possibility that the automation performance will decrease, but stability will go up)
If the element still can't be found maybe try building an XPath using the UI Inspector App.

Hopefully this was of any help.

@jknguyen621
Copy link

@miksch123 can you please give working code example of your wait? I am also experience same issue.

@miksch123
Copy link

new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(X => X.FindElement(By.XPath("element/you/found/using/afm")));

Here you go. This is a c# example as I am using that mainly.

@jknguyen621
Copy link

jknguyen621 commented Nov 7, 2020 via email

@toruncem
Copy link

did you get this working Joseph?

@miksch123
Copy link

Probably as there is no response that it didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants