appium / appium-for-mac

[deprecated] Application for automating a mac app with JSON wire protocol
Apache License 2.0
193 stars 70 forks source link

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

Open AryaKrishnan08 opened 4 years ago

AryaKrishnan08 commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

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

miksch123 commented 3 years ago

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 commented 3 years ago

Thank you. I will have to try this out.

Joseph

On Fri, Nov 6, 2020, 11:49 PM miksch123 notifications@github.com wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/appium/appium-for-mac/issues/86#issuecomment-723414358, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHU7LHLY2GPFRNM7XYICYJLSOT3XZANCNFSM4MYXSL4A .

toruncem commented 1 year ago

did you get this working Joseph?

miksch123 commented 1 year ago

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