-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat: Allow to configure host/port/app path for Appium for mac app in appium-mac-driver #42
Conversation
Hello Kazu, [HTTP] {"desiredCapabilities":{"app":"Switchboard - Dev","noReset":"false","a4mPort":9092,"newCommandTimeout":30000,"platformVersion":"10.15.1","a4mHost":"localhost","platformName":"Mac","deviceName":"Mac"},"capabilities":{"firstMatch":[{"a4mHost":"localhost","a4mPort":9092,"appium:app":"Switchboard - Dev","appium:deviceName":"Mac","appium:newCommandTimeout":30000,"appium:noReset":"false","platformName":"mac","appium:platformVersion":"10.15.1"}]}} |
Hmm. btw, my working branch should be MacDriver 1.8.0 base. |
@KazuCocoa [HTTP] {"desiredCapabilities":{"app":"Switchboard - Dev","noReset":"false","a4mPort":9092,"newCommandTimeout":30000,"platformVersion":"10.15.1","a4mHost":"127.0.0.1","platformName":"mac","deviceName":"mac"},"capabilities":{"firstMatch":[{"a4mHost":"127.0.0.1","a4mPort":9092,"appium:app":"Switchboard - Dev","appium:deviceName":"mac","appium:newCommandTimeout":30000,"appium:noReset":"false","platformName":"mac","appium:platformVersion":"10.15.1"}]}} |
git clone can do in another directory. |
@KazuCocoa :- i updated the driver, both caps are taken as input but not used, i have attached logs. |
Could you attach steps you did?
|
@KazuCocoa , I performed below steps
it picked the assigned port but failed to start the server as appium for mac application is still running on 4622 as per line And can we keep the port to get assigned on run time, like we have for appium -->builder.usingAnyFreePort();[Appium] a4mHost: 127.0.0.1 |
Thanks. This PR fixes below line in appium/appium-for-mac#79
In the issue, Appium tried to communicate with server running on mac as
The Appium4Mac was not this PR's scope. You changed the port by yourself in appium/appium-for-mac#79 as port |
@KazuCocoa :- the main issue still remains, Mac driver is not able to establish connection with AppiumforMac server as they are not listening to same port. |
Ah... do you expect MacDriver will detect the port used by AppiumforMac inside this driver? MacDriver expects users to set communication port properly as capabilities by themselves like other Appium's drivers. So, for example:
|
Both look absolutely right(literally was looking for this,thank you!!!), so in this way AppiumforMac run on any port and driver get what port it is running and connect to that , same way in next round it will different port and hence parallel execution will be possible.(at least my idea of it, what are your thoughts?) |
I hardcoded the port in https://github.com/appium/appium-for-mac/blob/2356957dc73b6275262c918ca8f4184ef4a25af0/AppiumForMac/AppiumForMacAppDelegate.m#L36 and build the app. |
@KazuCocoa , would it be possible to do something with driver, or build multiple apps with specific port , like you did in second example? that way each app will be responsible for one session. |
This way, for now since the a4mac app does not have dynamic listening port change feature. |
@KazuCocoa . Thanks for the updates, are these changes available to master? * a4mAppPath related changes. |
Appium old session will be killed by the new one or will different Appium4Mac application names wont kill anything which dont match? |
ah, currently a4mAppPath related change is in this branch. |
| `a4mPort` | Specify the port to the app for mac application. Defaults to `4622` | e.g, `4622`, `8080` | | ||
| `a4mAppPath` | Specify the path to the app for mac application. It helps to launch `AppiumForMac` application in a custom path. Defaults to `/Applications/AppiumForMac.app` | e.g, `/Applications/CustomAppiumForMac.app` | | ||
| `killAllA4MAppBeforeStart` | Kill all running processes named `AppiumForMac` not to remain the process in next Appium session run. Please disable this value when you run multiple `AppiumForMac` on the machine. Defaults to `true` | `false`, `true` | | ||
| `implicitTimeout` | | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update other capabilities after this PR
@@ -55,7 +59,7 @@ class AppiumForMac { | |||
`signal ${signal}`; | |||
log.error(msg); | |||
}); | |||
log.info(`Spawning AppiumForMac with: ${this.appium4macdriver}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone did not use this. appium4macdriver
. So, the value was always undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why where we spawning? And is there a way we can close the app after test, i mean another capability to kill /close the app on OS/machine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled the process by https://github.com/appium/node-teen_process/blob/56a139cbf86b819398d7736a442b6c4a985bc716/lib/subprocess.js#L23
The process will stop in delete the session in general.
https://github.com/appium/appium-mac-driver/blob/master/lib/driver.js#L58
So, the kill all process aims to make a new process run safer.
|----------|-----------|------| | ||
| `AppiumForMac` | Specify the host name to the app for mac application. Defaults to `127.0.0.1` | e.g., `localhost` | | ||
| `a4mPort` | Specify the port to the app for mac application. Defaults to `4622` | e.g, `4622`, `8080` | | ||
| `a4mAppPath` | Specify the path to the app for mac application. It helps to launch `AppiumForMac` application in a custom path. Defaults to `/Applications/AppiumForMac.app` | e.g, `/Applications/CustomAppiumForMac.app` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be smarter to find the app by its bundle id using searchd automatically if this cap is not set: https://apple.stackexchange.com/questions/115947/locating-an-app-by-its-bundle-identifier-from-the-command-line
| `AppiumForMac` | Specify the host name to the app for mac application. Defaults to `127.0.0.1` | e.g., `localhost` | | ||
| `a4mPort` | Specify the port to the app for mac application. Defaults to `4622` | e.g, `4622`, `8080` | | ||
| `a4mAppPath` | Specify the path to the app for mac application. It helps to launch `AppiumForMac` application in a custom path. Defaults to `/Applications/AppiumForMac.app` | e.g, `/Applications/CustomAppiumForMac.app` | | ||
| `killAllA4MAppBeforeStart` | Kill all running processes named `AppiumForMac` not to remain the process in next Appium session run. Please disable this value when you run multiple `AppiumForMac` on the machine. Defaults to `true` | `false`, `true` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we would need some separate tutorial on how to run parallel a4m sessions
You can launch multiple `AppiumForMac` on a same machine to run tests in parallel. | ||
Please consider to set `a4mPort`, `a4mAppPath` and `killAllA4MAppBeforeStart` as their capabilities to handle multiple Appium sessions on the machine. | ||
You must modify [the port number in appium-for-mac](https://github.com/appium/appium-for-mac/blob/2356957dc73b6275262c918ca8f4184ef4a25af0/AppiumForMac/AppiumForMacAppDelegate.m#L36) and build the app to coordinate the port number on `AppiumForMac`. Appium-mac-driver tries to establish a session to the host/port referencing `a4mPort` and `a4mAppPath`. | ||
Do not forget to handle your test scenarios properly not to conflict each other since the scenarios runs on the machine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on the same machine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the scenario runs
or scenarios run
if (!await fs.exists(REQ_A4M_APP_PATH)) { | ||
throw new Error('Could not verify AppiumForMacDriver install; please install to your /Applications folder'); | ||
if (!await fs.exists(this.a4mAppPath)) { | ||
throw new Error(`Could not verify AppiumForMacDriver install in ${this.a4mAppPath}; please install it to ${this.a4mAppPath}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is a good practice to put variable values in quotes, so people could easily extract them if they contain spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same below
[updated]
This PR allows users to configure port/host/path to connect to appium-for-mac. Users must build a4m after changing https://github.com/appium/appium-for-mac/blob/2356957dc73b6275262c918ca8f4184ef4a25af0/AppiumForMac/AppiumForMacAppDelegate.m#L36 . So, this usage is a more advanced one.
Related to appium/appium-for-mac#79
@sankalpphirke
What about with this branch?
You can configure the host/port with
a4mHost
anda4mPort
capabilities.i.e.
You can: