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

WD Proxy unable to get Appium4Mac http server port #79

Closed sankalphirke closed 4 years ago

sankalphirke commented 4 years ago

I am trying to create parallel execution for macos application and thought of creating appium4mac instances on different port and run/switch between them as required. But i am getting below issue

[Appium] Welcome to Appium v1.16.0-rc.1 [Appium] Non-default server args: [Appium] address: 127.0.0.1 [Appium] port: 11154 [Appium] defaultCapabilities: { [Appium] app: Convo Dev [Appium] deviceName: Mac [Appium] newCommandTimeout: 300 [Appium] noReset: false [Appium] platformName: Mac [Appium] } [Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities: [Appium] app: Convo Dev [Appium] deviceName: Mac [Appium] newCommandTimeout: 300 [Appium] noReset: false [Appium] platformName: Mac [Appium] Appium REST http interface listener started on 127.0.0.1:11154 [HTTP] --> GET /wd/hub/status [HTTP] {} [debug] [GENERIC] Calling AppiumDriver.getStatus() with args: [] [debug] [GENERIC] Responding to client with driver.getStatus() result: {"build":{"version":"1.16.0-rc.1"}} [HTTP] <-- GET /wd/hub/status 200 4 ms - 73 [HTTP] [HTTP] --> GET /wd/hub/status [HTTP] {} [debug] [GENERIC] Calling AppiumDriver.getStatus() with args: [] [debug] [GENERIC] Responding to client with driver.getStatus() result: {"build":{"version":"1.16.0-rc.1"}} [HTTP] <-- GET /wd/hub/status 200 1 ms - 73 [HTTP] [HTTP] --> POST /wd/hub/session [HTTP] {"desiredCapabilities":{"app":"Convo Dev","noReset":"false","platformName":"Mac","deviceName":"Mac","newCommandTimeout":300},"capabilities":{"firstMatch":[{"appium:app":"Convo Dev","appium:deviceName":"Mac","appium:newCommandTimeout":300,"appium:noReset":"false","platformName":"mac"}]}} [debug] [W3C] Calling AppiumDriver.createSession() with args: [{"app":"Convo Dev","noReset":"false","platformName":"Mac","deviceName":"Mac","newCommandTimeout":300},null,{"firstMatch":[{"appium:app":"Convo Dev","appium:deviceName":"Mac","appium:newCommandTimeout":300,"appium:noReset":"false","platformName":"mac"}]}] [debug] [BaseDriver] Event 'newSessionRequested' logged at 1577089419988 (13:53:39 GMT+0530 (India Standard Time)) [Appium] Appium v1.16.0-rc.1 creating new MacDriver (v1.7.0) session [debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided [debug] [BaseDriver] Creating session with W3C capabilities: { [debug] [BaseDriver] "alwaysMatch": { [debug] [BaseDriver] "platformName": "mac", [debug] [BaseDriver] "appium:app": "Convo Dev", [debug] [BaseDriver] "appium:deviceName": "Mac", [debug] [BaseDriver] "appium:newCommandTimeout": 300, [debug] [BaseDriver] "appium:noReset": "false" [debug] [BaseDriver] }, [debug] [BaseDriver] "firstMatch": [ [debug] [BaseDriver] {} [debug] [BaseDriver] ] [debug] [BaseDriver] } [BaseDriver] Capability 'noReset' changed from string to boolean. This may cause unexpected behavior [BaseDriver] The following capabilities were provided, but are not recognized by Appium: [BaseDriver] app [BaseDriver] Session created with session id: 9f33bd01-850d-4fe7-9e78-acae62153bc4 [MacDriver] Killing any old AppiumForMac [MacDriver] Successfully cleaned up old Appium4Mac servers [MacDriver] Spawning AppiumForMac with: undefined [Appium4Mac] [STDERR] 2019-12-23 13:53:40:165 AppiumForMac[1768:307] HTTPServer: Started HTTP server on port 50369 [debug] [WD Proxy] Matched '/session' to command name 'createSession' [debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:4622/wd/hub/session] with body: {"desiredCapabilities":{"platformName":"mac","app":"Convo Dev","deviceName":"Mac","newCommandTimeout":300,"noReset":false}} [WD Proxy] Got an unexpected response with status undefined: {"errno":-61,"code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":4622} [debug] [MacDriver] Deleting AppiumForMac session [debug] [BaseDriver] Event 'newSessionStarted' logged at 1577089420185 (13:53:40 GMT+0530 (India Standard Time)) [debug] [W3C] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: connect ECONNREFUSED 127.0.0.1:4622 [debug] [W3C] at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:270:13) [HTTP] <-- POST /wd/hub/session 500 215 ms - 572 [HTTP] org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: connect ECONNREFUSED 127.0.0.1:4622 Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'INFPUMAC07.local', ip: '2401:4900:197f:410d:20da:227e:8ee3:2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.1', java.version: '1.8.0_231' Driver info: driver.version: AppiumDriver remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: connect ECONNREFUSED 127.0.0.1:4622 at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:270:13) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'INFPUMAC07.local', ip: '2401:4900:197f:410d:20da:227e:8ee3:2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.1', java.version: '1.8.0_231' Driver info: driver.version: AppiumDriver at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217) 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:42) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:84) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:105) at config.Utils.CD(Utils.java:172) at pages.MacOS_App_pageobjects.(MacOS_App_pageobjects.java:19) at testcases.MacosApp.login_macos_app(MacosApp.java:16) 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124) at org.testng.internal.Invoker.invokeMethod(Invoker.java:583) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.privateRun(TestRunner.java:648) at org.testng.TestRunner.run(TestRunner.java:505) at org.testng.SuiteRun

KazuCocoa commented 4 years ago

Perhaps https://github.com/appium/appium-mac-driver/blob/789b3678297ba64a53be89f98e2d9570016d0eaf/lib/appium-for-mac.js#L16-L17 should be configurable (not supported yet)

sankalphirke commented 4 years ago

Thanks for the response. I tried configuring it with different ways but could not succeed , if you could help me getting this done.

const DEFAULT_A4M_HOST = '127.0.0.1'; exports.DEFAULT_A4M_HOST = DEFAULT_A4M_HOST; const DEFAULT_A4M_PORT = await this.getPort(); exports.DEFAULT_A4M_PORT = DEFAULT_A4M_PORT;

async getPort() { const { execSync } = require('child_process'); const stdout = execSync('lsof -i -P -n | grep AppiumFor'); var stdout1 = String(stdout); var patt1 = /*:(.*?)(/; var result = stdout1.match(patt1)[1]; this.DEFAULT_A4M_PORT = result.trim(); _logger.default.debug(result) return result; } -------------------------------------- Long/hard way--------------------------------- I don't know which file is responsible for starting the server, so if i could export the port from that class and assign it here then i could ask proxy to run on same port.

KazuCocoa commented 4 years ago

Made the port configurable by appium-mac-driver. The port should be managed by test script side via capabilities as Appium's design.