appium / appium

Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
http://appium.io/
Apache License 2.0
18.71k stars 6.06k forks source link

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. #13163

Closed BSayani closed 5 years ago

BSayani commented 5 years ago

## The problem

Unable to locate the element of desktop application of Mac OS X platform.

Environment

Details

Hi There,

I am looking for automating the Mac OS desktop application Microsoft word . My application uses Microsoft office word plugin. Frontend technologies: Microsoft Office js and Angular OS: MacOS Mojave Devoice:MacBook Pro (15-inch, 2019)

I have successfully open the Microsoft word app in my machine. But whenver I am trying to create a blank document in word. It’s not happening, my code not able to locate elements. For identifying elements, I am using tools UIElementInspector & Accessibilty Inspector. Have added the mentioned tools in the security & privacy of system preferences. Using Appium-1.13.0-mac.zip

Created couple of xpaths , but every time I am trying to run the code, it throws error message ‘org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. ’

The code throws error whenever it reached to xpath like:

WebElement blankDoc= driver.findElementByXPath( "/AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document']");

WebElement createBtn= driver.findElementByXPath( "/AXApplication[@AXRoleDescription=‘application’ and @AXTitle=‘Word’]/AXWindow[@AXTitle=‘Open new and recent files’ and @AXSubrole=‘AXStandardWindow’]/AXButton[@AXTitle=‘Create’ and @ AXRoleDescription=‘button’]");

Note:Whenever I run my code it throws error message ‘io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0 INFO: Detected dialect: W3C’

Regards, Sayani

## Appium logs

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. [35m[Appium][39m Welcome to Appium v1.14.2 [35m[Appium][39m Non-default server args: [35m[Appium][39m address: 127.0.0.1 [35m[Appium][39m Appium REST http interface listener started on 127.0.0.1:4723 [35m[HTTP][39m [37m-->[39m [37mGET[39m [37m/wd/hub/status[39m [35m[HTTP][39m [90m{}[39m [debug] [35m[GENERIC][39m Calling AppiumDriver.getStatus() with args: [] [debug] [35m[GENERIC][39m Responding to client with driver.getStatus() result: {"build":{"version":"1.14.2"}} [35m[HTTP][39m [37m<-- GET /wd/hub/status [39m[32m200[39m [90m5 ms - 68[39m [35m[HTTP][39m [90m[39m [35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session[39m [35m[HTTP][39m [90m{"desiredCapabilities":{"app":"Microsoft Word","platformName":"Mac","deviceName":"Mac","newCommandTimeout":300},"capabilities":{"firstMatch":[{"appium:app":"Microsoft Word","appium:deviceName":"Mac","appium:newCommandTimeout":300,"platformName":"mac"}]}}[39m [debug] [35m[W3C][39m Calling AppiumDriver.createSession() with args: [{"app":"Microsoft Word","platformName":"Mac","deviceName":"Mac","newCommandTimeout":300},null,{"firstMatch":[{"appium:app":"Microsoft Word","appium:deviceName":"Mac","appium:newCommandTimeout":300,"platformName":"mac"}]}] [debug] [35m[BaseDriver][39m Event 'newSessionRequested' logged at 1567397154304 (09:35:54 GMT+0530 (India Standard Time)) [35m[Appium][39m Appium v1.14.2 creating new MacDriver (v1.4.1) session [35m[Appium][39m Capabilities: [35m[Appium][39m platformName: mac [35m[Appium][39m app: Microsoft Word [35m[Appium][39m deviceName: Mac [35m[Appium][39m newCommandTimeout: 300 [debug] [35m[BaseDriver][39m W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities {"app":"Microsoft Word","pl... were provided [debug] [35m[BaseDriver][39m Creating session with W3C capabilities: {"alwaysMatch":{"platformNa... [35m[BaseDriver][39m The following capabilities were provided, but are not recognized by Appium: [35m[BaseDriver][39m app [35m[BaseDriver][39m Session created with session id: 5c09a2ee-c62f-4287-b920-c93b022b0166 [35m[MacDriver][39m Killing any old AppiumForMac [35m[MacDriver][39m Successfully cleaned up old Appium4Mac servers [35m[MacDriver][39m Spawning AppiumForMac with: undefined [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:35:54:461 AppiumForMac[1025:307] HTTPServer: Started HTTP server on port 4622 [debug] [35m[WD Proxy][39m Matched '/session' to command name 'createSession' [debug] [35m[WD Proxy][39m Proxying [POST /session] to [POST http://127.0.0.1:4622/wd/hub/session] with body: {"desiredCapabilities":{"platformName":"mac","app":"Microsoft Word","deviceName":"Mac","newCommandTimeout":300}} [debug] [35m[WD Proxy][39m Got response with status 200: {"status":0,"sessionId":"EfrguptN","value":{"locationContextEnabled":false,"webStorageEnabled":false,"browserName":"Mac","platform":"Mac","databaseEnabled":false,"version":"10.14.6","javascriptEnabled":true,"takesScreenshot":true,"nativeEvents":true}} [debug] [35m[WD Proxy][39m Determined that the downstream protocol for proxy is MJSONWP [35m[MacDriver][39m Automatically navigating to app 'Microsoft Word' [debug] [35m[WD Proxy][39m Matched '/url' to command name 'setUrl' [debug] [35m[WD Proxy][39m Proxying [POST /url] to [POST http://127.0.0.1:4622/wd/hub/session/EfrguptN/url] with body: {"url":"Microsoft Word"} [debug] [35m[WD Proxy][39m Got response with status 200: {"status":0,"sessionId":"EfrguptN"} [35m[Appium][39m New MacDriver session created successfully, session 5c09a2ee-c62f-4287-b920-c93b022b0166 added to master session list [debug] [35m[BaseDriver][39m Event 'newSessionStarted' logged at 1567397155692 (09:35:55 GMT+0530 (India Standard Time)) [debug] [35m[W3C (5c09a2ee)][39m Cached the protocol value 'W3C' for the new session 5c09a2ee-c62f-4287-b920-c93b022b0166 [debug] [35m[W3C (5c09a2ee)][39m Responding to client with driver.createSession() result: {"capabilities":{"platformName":"mac","app":"Microsoft Word","deviceName":"Mac","newCommandTimeout":300}} [35m[HTTP][39m [37m<-- POST /wd/hub/session [39m[32m200[39m [90m1390 ms - 166[39m [35m[HTTP][39m [90m[39m Sep 02, 2019 9:35:55 AM io.appium.javaclient.remote.AppiumCommandExecutor$1 lambda$0 INFO: Detected dialect: W3C [35m[HTTP][39m [37m-->[39m [37mGET[39m [37m/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166[39m [35m[HTTP][39m [90m{}[39m [35m[W3C (5c09a2ee)][39m Driver proxy active, passing request on via HTTP proxy [debug] [35m[WD Proxy][39m Matched '/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166' to command name 'getSession' [debug] [35m[WD Proxy][39m Proxying [GET /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166] to [GET http://127.0.0.1:4622/wd/hub/session/EfrguptN] with body: {} [debug] [35m[WD Proxy][39m Got response with status 200: "{\n \"status\" : 0,\n \"sessionId\" : \"EfrguptN\",\n \"value\" : {\n \"locationContextEnabled\" : false,\n \"webStorageEnabled\" : false,\n \"browserName\" : \"Mac\",\n \"platform\" : \"Mac\",\n \"databaseEnabled\" : false,\n \"version\" : \"10.14.6\",\n \"javascriptEnabled\" : true,\n \"takesScreenshot\" : true,\n \"nativeEvents\" : true\n }\n}" [35m[WD Proxy][39m Replacing sessionId EfrguptN with 5c09a2ee-c62f-4287-b920-c93b022b0166 [35m[HTTP][39m [37m<-- GET /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166 [39m[32m200[39m [90m22 ms - 279[39m [35m[HTTP][39m [90m[39m [35m[HTTP][39m [37m-->[39m [37mGET[39m [37m/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166[39m [35m[HTTP][39m [90m{}[39m [35m[W3C (5c09a2ee)][39m Driver proxy active, passing request on via HTTP proxy [debug] [35m[WD Proxy][39m Matched '/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166' to command name 'getSession' [debug] [35m[WD Proxy][39m Proxying [GET /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166] to [GET http://127.0.0.1:4622/wd/hub/session/EfrguptN] with body: {} [debug] [35m[WD Proxy][39m Got response with status 200: "{\n \"status\" : 0,\n \"sessionId\" : \"EfrguptN\",\n \"value\" : {\n \"locationContextEnabled\" : false,\n \"webStorageEnabled\" : false,\n \"browserName\" : \"Mac\",\n \"platform\" : \"Mac\",\n \"databaseEnabled\" : false,\n \"version\" : \"10.14.6\",\n \"javascriptEnabled\" : true,\n \"takesScreenshot\" : true,\n \"nativeEvents\" : true\n }\n}" [35m[WD Proxy][39m Replacing sessionId EfrguptN with 5c09a2ee-c62f-4287-b920-c93b022b0166 [35m[HTTP][39m [37m<-- GET /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166 [39m[32m200[39m [90m3 ms - 279[39m [35m[HTTP][39m [90m[39m [35m[HTTP][39m [37m-->[39m [37mGET[39m [37m/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166[39m [35m[HTTP][39m [90m{}[39m [35m[W3C (5c09a2ee)][39m Driver proxy active, passing request on via HTTP proxy [debug] [35m[WD Proxy][39m Matched '/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166' to command name 'getSession' [debug] [35m[WD Proxy][39m Proxying [GET /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166] to [GET http://127.0.0.1:4622/wd/hub/session/EfrguptN] with body: {} [debug] [35m[WD Proxy][39m Got response with status 200: "{\n \"status\" : 0,\n \"sessionId\" : \"EfrguptN\",\n \"value\" : {\n \"locationContextEnabled\" : false,\n \"webStorageEnabled\" : false,\n \"browserName\" : \"Mac\",\n \"platform\" : \"Mac\",\n \"databaseEnabled\" : false,\n \"version\" : \"10.14.6\",\n \"javascriptEnabled\" : true,\n \"takesScreenshot\" : true,\n \"nativeEvents\" : true\n }\n}" [35m[WD Proxy][39m Replacing sessionId EfrguptN with 5c09a2ee-c62f-4287-b920-c93b022b0166 [35m[HTTP][39m [37m<-- GET /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166 [39m[32m200[39m [90m3 ms - 279[39m [35m[HTTP][39m [90m[39m [35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166/timeouts[39m [35m[HTTP][39m [90m{"implicit":5000}[39m [35m[W3C (5c09a2ee)][39m Driver proxy active, passing request on via HTTP proxy [debug] [35m[WD Proxy][39m Matched '/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166/timeouts' to command name 'timeouts' [debug] [35m[Protocol Converter][39m Will send the following request bodies to /timeouts: [{"type":"implicit","ms":5000}] [debug] [35m[WD Proxy][39m Proxying [POST /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166/timeouts] to [POST http://127.0.0.1:4622/wd/hub/session/EfrguptN/timeouts] with body: {"type":"implicit","ms":5000} [debug] [35m[WD Proxy][39m Got response with status 200: {"status":0,"sessionId":"EfrguptN","value":"0"} [35m[WD Proxy][39m Replacing sessionId EfrguptN with 5c09a2ee-c62f-4287-b920-c93b022b0166 [35m[HTTP][39m [37m<-- POST /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166/timeouts [39m[32m200[39m [90m4 ms - 75[39m [35m[HTTP][39m [90m[39m [35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166/element[39m [35m[HTTP][39m [90m{"using":"xpath","value":"/AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document']"}[39m [35m[W3C (5c09a2ee)][39m Driver proxy active, passing request on via HTTP proxy [debug] [35m[WD Proxy][39m Matched '/wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166/element' to command name 'findElement' [debug] [35m[WD Proxy][39m Proxying [POST /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166/element] to [POST http://127.0.0.1:4622/wd/hub/session/EfrguptN/element] with body: {"using":"xpath","value":"/AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document']"} [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:04.884 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath: /AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document'] [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:04.884 AppiumForMac[1025:42295] axPathComponents:( [35m[Appium4Mac][39m [STDERR] "AXApplication[@AXTitle='Word']", [35m[Appium4Mac][39m [STDERR] "AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']", [35m[Appium4Mac][39m [STDERR] "AXScrollArea[0]", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXCollectionList']", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXSectionList']", [35m[Appium4Mac][39m [STDERR] "AXGroup[@AXIdentifier='DocsUITemplate']", [35m[Appium4Mac][39m [STDERR] "AXButton[@AXTitle='Blank Document']" [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:04.899 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath matchedNodes:( [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:05.904 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath: /AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document'] [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:05.904 AppiumForMac[1025:42295] axPathComponents:( [35m[Appium4Mac][39m [STDERR] "AXApplication[@AXTitle='Word']", [35m[Appium4Mac][39m [STDERR] "AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']", [35m[Appium4Mac][39m [STDERR] "AXScrollArea[0]", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXCollectionList']", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXSectionList']", [35m[Appium4Mac][39m [STDERR] "AXGroup[@AXIdentifier='DocsUITemplate']", [35m[Appium4Mac][39m [STDERR] "AXButton[@AXTitle='Blank Document']" [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:05.904 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath matchedNodes:( [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:06.907 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath: /AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document'] [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:06.907 AppiumForMac[1025:42295] axPathComponents:( [35m[Appium4Mac][39m [STDERR] "AXApplication[@AXTitle='Word']", [35m[Appium4Mac][39m [STDERR] "AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']", [35m[Appium4Mac][39m [STDERR] "AXScrollArea[0]", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXCollectionList']", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXSectionList']", [35m[Appium4Mac][39m [STDERR] "AXGroup[@AXIdentifier='DocsUITemplate']", [35m[Appium4Mac][39m [STDERR] "AXButton[@AXTitle='Blank Document']" [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:06.907 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath matchedNodes:( [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:07.911 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath: /AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document'] [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:07.912 AppiumForMac[1025:42295] axPathComponents:( [35m[Appium4Mac][39m [STDERR] "AXApplication[@AXTitle='Word']", [35m[Appium4Mac][39m [STDERR] "AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']", [35m[Appium4Mac][39m [STDERR] "AXScrollArea[0]", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXCollectionList']", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXSectionList']", [35m[Appium4Mac][39m [STDERR] "AXGroup[@AXIdentifier='DocsUITemplate']", [35m[Appium4Mac][39m [STDERR] "AXButton[@AXTitle='Blank Document']" [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:07.912 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath matchedNodes:( [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:08.917 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath: /AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document'] [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:08.917 AppiumForMac[1025:42295] axPathComponents:( [35m[Appium4Mac][39m [STDERR] "AXApplication[@AXTitle='Word']", [35m[Appium4Mac][39m [STDERR] "AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']", [35m[Appium4Mac][39m [STDERR] "AXScrollArea[0]", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXCollectionList']", [35m[Appium4Mac][39m [STDERR] "AXList[@AXSubrole='AXSectionList']", [35m[Appium4Mac][39m [STDERR] "AXGroup[@AXIdentifier='DocsUITemplate']", [35m[Appium4Mac][39m [STDERR] "AXButton[@AXTitle='Blank Document']" [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] 2019-09-02 09:36:08.917 AppiumForMac[1025:42295] [35m[Appium4Mac][39m [STDERR] ***** findAllUsingAbsoluteAXPath matchedNodes:( [35m[Appium4Mac][39m [STDERR] ) [35m[Appium4Mac][39m [STDERR] [35m[Appium4Mac][39m [STDERR] [debug] [35m[WD Proxy][39m Got response with status 200: {"status":7,"sessionId":"EfrguptN","value":{"message":"An element could not be located on the page using the given search parameters."}} [35m[WD Proxy][39m Got an unexpected response: {"status":7,"sessionId":"EfrguptN","value":{"message":"An element could not be located on the page using the given search parameters."}} [debug] [35m[W3C (5c09a2ee)][39m Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: The request to /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166/element has failed [debug] [35m[W3C (5c09a2ee)]_[39m at JWProxy.proxy (/usr/local/lib/node_modules/appium/nodemodules/appium-base-driver/lib/jsonwp-proxy/proxy.js:183:13) [debug] [35m[W3C (5c09a2ee)]_[39m at ProtocolConverter.convertAndProxy (/usr/local/lib/node_modules/appium/nodemodules/appium-base-driver/lib/jsonwp-proxy/protocol-converter.js:226:12) [debug] [35m[W3C (5c09a2ee)]_[39m at JWProxy.proxyCommand (/usr/local/lib/node_modules/appium/nodemodules/appium-base-driver/lib/jsonwp-proxy/proxy.js:227:12) [debug] [35m[W3C (5c09a2ee)]_[39m at JWProxy.proxyReqRes (/usr/local/lib/node_modules/appium/nodemodules/appium-base-driver/lib/jsonwp-proxy/proxy.js:278:28) [debug] [35m[MJSONWP][39m Matched JSONWP error code 7 to NoSuchElementError [35m[HTTP][39m [37m<-- POST /wd/hub/session/5c09a2ee-c62f-4287-b920-c93b022b0166/element [39m[33m404[39m [90m5040 ms - 672[39m [35m[HTTP][39m [90m_[39m org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'Apttuss-MacBook-Pro.local', ip: 'fe80:0:0:0:453:19dd:ebda:d487%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_221' Driver info: io.appium.java_client.AppiumDriver Capabilities {app: Microsoft Word, deviceName: Mac, javascriptEnabled: true, newCommandTimeout: 300, platform: MAC, platformName: Mac} Session ID: 5c09a2ee-c62f-4287-b920-c93b022b0166 *** Element info: {Using=xpath, value=/AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document']} 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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323) at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:61) at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428) at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:151) at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1) at com.apttus.xajs.auto.Automate_Mac.testActivityMonitor(Automate_Mac.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

## Code To Reproduce Issue [ Good To Have ]

import io.appium.java_client.AppiumDriver;

import io.appium.java_client.service.local.AppiumDriverLocalService;

import io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException;

import io.appium.java_client.service.local.AppiumServiceBuilder;

import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; //import org.aspectj.lang.annotation.Before; import org.openqa.selenium.WebElement;

import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait;

import java.io.File;

import java.io.IOException;

import java.net.URL;

import java.util.concurrent.TimeUnit;

public class Automate_Mac

{

private AppiumDriver driver;

public AppiumDriverLocalService service = null;

@SuppressWarnings("raswtypes")

@Before

public void setUp() throws IOException {

    try {

        service = AppiumDriverLocalService

                .buildService(new AppiumServiceBuilder()

                        .usingDriverExecutable(new File("/usr/local/bin/node"))

                        .withAppiumJS(

                                new File(

                                        "/usr/local/lib/node_modules/appium/build/lib/main.js"))

                        .withIPAddress("127.0.0.1").usingPort(4723));

        service.start();

        DesiredCapabilities caps = new DesiredCapabilities();

        caps.setCapability("platformName", "Mac");

        caps.setCapability("deviceName", "Mac");

        caps.setCapability("app", "Microsoft Word");
        // caps.setCapability("app", "Activity Monitor");

        caps.setCapability("newCommandTimeout", 300);

        driver = new AppiumDriver(new URL("http://localhost:4723/wd/hub"), caps);

        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

    } catch (AppiumServerHasNotBeenStartedLocallyException e) {

        // TODO Auto-generated catch block

        service.stop();

        e.printStackTrace();

    }

}

@Test

public void testActivityMonitor() {
    WebElement blankDoc = null, createBtn = null;
    WebElement tryEle = null;
    try {

        Thread.sleep(115);

        blankDoc = driver.findElementByXPath(
                "/AXApplication[@AXTitle='Word']/AXWindow[@AXTitle='Open new and recent files' and @AXIdentifier='DocStage' and @AXSubrole='AXStandardWindow']/AXScrollArea[0]/AXList[@AXSubrole='AXCollectionList']/AXList[@AXSubrole='AXSectionList']/AXGroup[@AXIdentifier='DocsUITemplate']/AXButton[@AXTitle='Blank Document']");
        blankDoc.click();

        // Create Button Xpath:

        createBtn = driver.findElementByXPath(
                "/AXApplication[@AXRoleDescription=‘application’ and @AXTitle=‘Word’]/AXWindow[@AXTitle=‘Open new and recent files’ and @AXSubrole=‘AXStandardWindow’]/AXButton[@AXTitle=‘Create’ and @ AXRoleDescription=‘button’]");
        createBtn.click();

    } catch (Exception e) {

        // TODO Auto-generated catch block
            // System.out.println("Create Button = " + createBtn.getSize());
        service.stop();

        e.printStackTrace();

    }

}

}

mykola-mokhnach commented 5 years ago

Please attach the output of page source command for the given screen

BSayani commented 5 years ago

Hi @mykola-mokhnach , I am new to appium for mac, are you talking about console result after execution of my code,if so then I am attaching the same. Console _Output.docx A

mykola-mokhnach commented 5 years ago

No, I'm talking about the output of the API method, which retrieves the XML source of the current page

BSayani commented 5 years ago

@mykola-mokhnach Thanks for the reply but I dnt have clue how to get the same.

mykola-mokhnach commented 5 years ago

Google search should help to get there

BSayani commented 5 years ago

hi @mykola-mokhnach , just a lill google and get the rough idea about the input which you are expecting . Before I share the inputs, few things I would like to mention: 1.The word which I have opened through code is just launching the word app not the creation of blank document. So as per the above, I have explicitly created the word and saved it in XML format and sharing the same with you. Hope my inputs is what you are expecting.

Doc_Automation.zip

mykola-mokhnach commented 5 years ago

How about https://www.google.com/search?q=selenium+get+page+source ?

BSayani commented 5 years ago

hi @mykola-mokhnach , just added the line String pageSource=driver.getPageSource(); System.out.println("Page source: ");
System.out.println(pageSource);

O/P: Page source: <?xml version="1.0"?>

mykola-mokhnach commented 5 years ago

I don't see nothing. Problems with markup?

BSayani commented 5 years ago

@mykola-mokhnach , the output of the driver.getPageSource is xml version="1.0"

mykola-mokhnach commented 5 years ago

If no xml is returned then it means that either osx driver cannot retrieve it from accessibility or there is an issue in the driver itself. Unfortunately, for both cases nothing could be done at this time, since we currently don't have any active osx driver maintainers.

BSayani commented 5 years ago

@mykola-mokhnach , so are you trying to say that there is no way to interact with MAC OS X desktop application through appium for mac. I have gone through couple of blogs , like https://journeyofquality.wordpress.com/category/automation-for-mac-desktop-applications/

shows that we can automate or interact with desktop application of MAC OS Mojave via appium for mac. Do I need to attach my appium server with the application opened with appium in MAC. If so, is there any way to do that?

mykola-mokhnach commented 5 years ago

Maybe not with this particular application

mykola-mokhnach commented 5 years ago

Although, it still requires investigation and someone has to do that

BSayani commented 5 years ago

I have gone through couple of blogs , like https://journeyofquality.wordpress.com/category/automation-for-mac-desktop-applications/

shows that we can automate or interact with desktop application of MAC OS Mojave via appium for mac. Do I need to attach my appium process with the application opened by appium in MAC. If so, is there any way to do that?

mykola-mokhnach commented 5 years ago

Please use Appium forum for howto questions

BSayani commented 5 years ago

Hey , as per the above conservation, let say we assume it appium for mac doesn't support the Word in MAC but how come the same piece of code not working for activity monitor. I think , m missing out something, can anyone help me plz.

sankalphirke commented 4 years ago

Have you tried using AppiumforMac masos application? You could find AXPath of desktop application with help of it.

  1. Install Appiumformac
  2. Mouse hover to the point you need AXPath
  3. Click Fn button and paste the clipboard content on notepad (Give required privilege to the app first)