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

AfM Unable to find elements, even with simple examples #101

Open aofl-esd opened 3 years ago

aofl-esd commented 3 years ago

I've been unable to get appium for mac to find elements. I created a simplified version of the textedit example:

from selenium import webdriver
import time

caps = {
    'platformName': 'Mac',
    'deviceName': 'Mac',
    'app': 'TextEdit'
}
driver = webdriver.Remote('http://localhost:4622/wd/hub', desired_capabilities=caps)

driver.get('TextEdit')
time.sleep(5)

try:
    window = driver.find_element_by_xpath("/AXApplication[@AXTitle='TextEdit']/AXWindow[0]")
finally:
    driver.quit()

The resulting error is: selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

In xcode, this is the console result from appium for mac:

2020-09-18 18:16:39.248971-0700 AppiumForMac[87822:1290991] Metal API Validation Enabled
2020-09-18 18:16:39:341 AppiumForMac[87822:307] HTTPServer: Started HTTP server on port 4622
=================================================================
Main Thread Checker: UI API called on a background thread: -[NSApplication delegate]
PID: 87822, TID: 1291775, Thread name: (none), Queue name: HTTPConnection, QoS: 0
Backtrace:
4   AppiumForMac                        0x000000010005f461 -[AfMHTTPConnection httpResponseForMethod:URI:] + 289
5   AppiumForMac                        0x0000000100017525 -[HTTPConnection replyToHTTPRequest] + 997
6   AppiumForMac                        0x000000010001c87c -[HTTPConnection socket:didReadData:withTag:] + 4828
7   AppiumForMac                        0x000000010003eddd __37-[GCDAsyncSocket completeCurrentRead]_block_invoke + 77
8   libdispatch.dylib                   0x00000001004aa844 _dispatch_call_block_and_release + 12
9   libdispatch.dylib                   0x00000001004ab826 _dispatch_client_callout + 8
10  libdispatch.dylib                   0x00000001004b2dd7 _dispatch_lane_serial_drain + 777
11  libdispatch.dylib                   0x00000001004b3b90 _dispatch_lane_invoke + 438
12  libdispatch.dylib                   0x00000001004c0fe0 _dispatch_workloop_worker_thread + 691
13  libsystem_pthread.dylib             0x0000000100539361 _pthread_wqthread + 290
14  libsystem_pthread.dylib             0x000000010053849b start_wqthread + 15
2020-09-18 18:17:29.360729-0700 AppiumForMac[87822:1291775] [reports] Main Thread Checker: UI API called on a background thread: -[NSApplication delegate]
PID: 87822, TID: 1291775, Thread name: (none), Queue name: HTTPConnection, QoS: 0
Backtrace:
4   AppiumForMac                        0x000000010005f461 -[AfMHTTPConnection httpResponseForMethod:URI:] + 289
5   AppiumForMac                        0x0000000100017525 -[HTTPConnection replyToHTTPRequest] + 997
6   AppiumForMac                        0x000000010001c87c -[HTTPConnection socket:didReadData:withTag:] + 4828
7   AppiumForMac                        0x000000010003eddd __37-[GCDAsyncSocket completeCurrentRead]_block_invoke + 77
8   libdispatch.dylib                   0x00000001004aa844 _dispatch_call_block_and_release + 12
9   libdispatch.dylib                   0x00000001004ab826 _dispatch_client_callout + 8
10  libdispatch.dylib                   0x00000001004b2dd7 _dispatch_lane_serial_drain + 777
11  libdispatch.dylib                   0x00000001004b3b90 _dispatch_lane_invoke + 438
12  libdispatch.dylib                   0x00000001004c0fe0 _dispatch_workloop_worker_thread + 691
13  libsystem_pthread.dylib             0x0000000100539361 _pthread_wqthread + 290
14  libsystem_pthread.dylib             0x000000010053849b start_wqthread + 15
2020-09-18 18:17:35.599582-0700 AppiumForMac[87822:1291425] 

************* findAllUsingAbsoluteAXPath: /AXApplication[@AXTitle='TextEdit']/AXWindow[0]
2020-09-18 18:17:35.599739-0700 AppiumForMac[87822:1291425] axPathComponents:(
    "AXApplication[@AXTitle='TextEdit']",
    "AXWindow[0]"
)
2020-09-18 18:17:35.660471-0700 AppiumForMac[87822:1291425] 
************* findAllUsingAbsoluteAXPath matchedNodes:(
)
murali238 commented 3 years ago

I too facing the same issue. Absolute AXPaths are not working anymore.

Rup1 commented 3 years ago

@aofl-esd That doesn't look like a full xpath, you need to use the full expath. hover over the element you're trying to access and click the fn button. This will copy the full xpath to the clipboard and you can then paste it in your code.