Closed harveykwan9 closed 1 month ago
Did you run tinyproxy
? Then, could you try out without the proxy runing?
From your attached log:
data: '<?xml version="1.0" encoding="UTF-8" ?>\n' +
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' +
'\n' +
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n' +
'\n' +
'<head>\n' +
'<title>500 Unable to connect</title>\n' +
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n' +
'</head>\n' +
'\n' +
'<body>\n' +
'\n' +
'<h1>Unable to connect</h1>\n' +
'\n' +
'<p>Tinyproxy was unable to connect to the remote web server.</p>\n' +
'\n' +
'<hr />\n' +
'\n' +
'<p><em>Generated by <a href="https://tinyproxy.github.io/">tinyproxy</a> version 1.10.0.</em></p>\n' +
'\n' +
'</body>\n' +
'\n' +
'</html>\n'
},
status: 500
My Apple M3 with macOS 14.5 (23F79) had no issue as below. I don't have any proxies.
[7afdb9d1][HTTP] --> GET /session/7afdb9d1-8f9a-4879-a5aa-c4c85f9368b5/contexts {}
[7afdb9d1][AndroidUiautomator2Driver@ca63] Calling AppiumDriver.getContexts() with args: ["7afdb9d1-8f9a-4879-a5aa-c4c85f9368b5"]
[7afdb9d1][AndroidUiautomator2Driver@ca63] Getting a list of available webviews
[7afdb9d1][ADB] Running '/Users/kazu/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell cat /proc/net/unix'
[7afdb9d1][AndroidUiautomator2Driver@ca63] Parsed 1 active devtools socket: ["@webview_devtools_remote_7709"]
[7afdb9d1][AndroidUiautomator2Driver@ca63] Collecting CDP data of 1 webview
[7afdb9d1][AndroidUiautomator2Driver@ca63] Forwarding remote port webview_devtools_remote_7709 to a local port in range 10900..11000
[7afdb9d1][AndroidUiautomator2Driver@ca63] You could use the 'webviewDevtoolsPort' capability to customize the starting port number
[7afdb9d1][ADB] Running '/Users/kazu/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 forward tcp:10900 localabstract:webview_devtools_remote_7709'
[7afdb9d1][ADB] Removing forwarded port socket connection: 10900
[7afdb9d1][ADB] Running '/Users/kazu/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp:10900'
[7afdb9d1][AndroidUiautomator2Driver@ca63] CDP data collection completed
[7afdb9d1][AndroidUiautomator2Driver@ca63] WEBVIEW_7709 mapped to pid 7709
[7afdb9d1][AndroidUiautomator2Driver@ca63] Getting process name for webview 'WEBVIEW_7709'
[7afdb9d1][ADB] Running '/Users/kazu/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell ps --help'
[7afdb9d1][ADB] Running '/Users/kazu/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell ps -A'
[7afdb9d1][AndroidUiautomator2Driver@ca63] Got process name: 'io.appium.android.apis'
[7afdb9d1][AndroidUiautomator2Driver@ca63] Found 1 webview: ["WEBVIEW_io.appium.android.apis"]
[7afdb9d1][AndroidUiautomator2Driver@ca63] Available contexts: ["NATIVE_APP","WEBVIEW_io.appium.android.apis"]
[7afdb9d1][AndroidUiautomator2Driver@ca63] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_io.appium.android.apis"]
[7afdb9d1][HTTP] <-- GET /session/7afdb9d1-8f9a-4879-a5aa-c4c85f9368b5/contexts 200 525 ms - 57
I had never run tinproxy, and did not have it installed. It's great to know that it is working with your computer, just need to figure out whats going on with mine right now 😢
Hey! was able to figure out the issue. It had to do with my environment variables.
I had export HTTP_PROXY={...}
set in my .zprofile
which for some reason was impacting the request which UIAutomator does to 127.0.0.1
to interact or connect to webviews.
The fix for me was to remove the line export HTTP_PROXY={...}
or to add export NO_PROXY=127.0.0.1
to my .zprofile
I assume it is an axios-specific feature. See, for example, https://www.scrapingbee.com/blog/nodejs-axios-proxy/ -> Setting a proxy via environment variables. Not sure if we should disable this feature explicitly in the wdproxy code @KazuCocoa @jlipps
Maybe then env var also could work for it instead of controlling it by Appium internally? https://github.com/axios/axios/blob/cda671af81ca87a00c6bf5a07bffcb07468756d3/README.md?plain=1#L530-L540
If any help is needed with this please let me know!
Hi!
I am unable to use Appium with UIAutomator2 (we tried multiple versions) with an android emulator on a Apple Mac M3 Pro laptop. On an M2 Pro laptop it works fine with the same package versions (Appium, UIAutomator2, Android Emulator OS API version)
Versions used:
Prerequisites:
Steps to reproduce:
package.json
as so:npm i
npx appium
"appium:app"
path)Refresh Source & Screenshot
-> clickCommands
at the top navigation -> clickContext
dropdown -> clickgetContexts
Expected results:
NATIVE_APP
andWEBVIEW_com.wdiodemoapp
app contextsActual results:
NATIVE_APP
context shown, no webview context is shownScreenshot of it working on a M2 Pro chip:
Screenshot of it not working on a M3 Pro chip:
Attached is a log of the
getContexts()
appium command execution with an error while executing the following command getContext-log.txt