Skip to content

Commit

Permalink
Merge pull request #148 from zebrunner/develop
Browse files Browse the repository at this point in the history
2.4 rc
  • Loading branch information
vdelendik authored Dec 27, 2022
2 parents 525f00c + b9afa2a commit f48657c
Show file tree
Hide file tree
Showing 7 changed files with 419 additions and 325 deletions.
3 changes: 3 additions & 0 deletions .env.original
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ AUTOMATION_NAME=XCUITest
WEBSOCKET_PROTOCOL=ws
WEB_PROTOCOL=http

WDA_HOST=localhost
WDA_BUNDLEID=com.facebook.WebDriverAgentRunner.xctrunner
WDA_WAIT_TIMEOUT=30
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ stf
*.log
metaData/connectedDevices.txt
metaData/simulators.txt
WebDriverAgent.ipa
16 changes: 11 additions & 5 deletions LaunchAgents/syncZebrunner.plist
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,35 @@
<string>/bin:/usr/bin:/usr/local/bin:/usr/sbin:/sbin</string>
</dict>
<key>Label</key>
<string>com.zebrunner.mcloud</string>
<string>com.zebrunner.mcloud.udid_value</string>
<key>ProgramArguments</key>
<array>
<string>./zebrunner.sh</string>
<string>start-services</string>
<string>recover</string>
<string>udid_value</string>
</array>
<key>WorkingDirectory</key>
<string>working_dir_value</string>
<key>UserName</key>
<string>user_value</string>
<key>KeepAlive</key>
<false/>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>

<key>RunAtLoad</key>
<true/>

<key>AbandonProcessGroup</key>
<true/>

<key>StartInterval</key>
<integer>15</integer>
<integer>0</integer>

<key>StandardErrorPath</key>
<string>logs/agents.log</string>
<key>StandardOutPath</key>
<string>logs/agents.log</string>
</dict>
</plist>

82 changes: 50 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Feel free to support the development with a [**donation**](https://www.paypal.co

## Software prerequisites
* Install XCode 11.2+
* Install npm 8.3.0 or higher
`npm install -g npm@8.3.0`
* Install [nvm](https://github.com/nvm-sh/nvm) version manager
> NVM required to organize automatic switch between nodes
* Using NVM install v17.1.0 for STF and the latest Appium compatible node version
* Make the Appium node as default one, for example:
`nvm alias default 17`
* Install Appium, optionally install opencv module to be able to support [find by image](https://zebrunner.github.io/carina/automation/mobile/#how-to-use-find-by-image-strategy) strategy
* Using NVM install node v17.1.0 and make it default `nvm alias default 17`
* Install Appium v1.22.3, optionally install opencv module to be able to support [find by image](https://zebrunner.github.io/carina/automation/mobile/#how-to-use-find-by-image-strategy) strategy
* Sign WebDriverAgent using your Dev Apple certificate and install WebDriverAgent on each device manually
* Open in XCode <i>APPIUM_HOME</i>/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj
* Choose WebDriverAgentRunner and your device(s)
Expand All @@ -27,7 +27,47 @@ Feel free to support the development with a [**donation**](https://www.paypal.co
* Install jq
`brew install jq`
* Install cmake to be able to compile jpeg-turbo: https://cmake.org/install
* Download go ios utility [go-ios-mac.zip](https://github.com/danielpaulus/go-ios/releases/latest/download/go-ios-mac.zip) and put into `/usr/local/bin`
* Download v1.0.98+ go ios utility [go-ios-mac.zip](https://github.com/danielpaulus/go-ios/releases/download/v1.0.98/go-ios-mac.zip) and put into `/usr/local/bin`

### Patch appium
* Clone Zebrunner Appium and patch sources:
```
git clone https://github.com/zebrunner/appium.git
cd appium
export APPIUM_HOME=/usr/local/lib/node_modules/appium
cp -R -v ./files/mcloud/* ${APPIUM_HOME}/
```
* Generate symlinks to shell scripts:
```
ln -s $HOME/tools/appium/files/concat-video-recordings.sh /opt/
ln -s $HOME/tools/appium/files/reset-logs.sh /opt/
ln -s $HOME/tools/appium/files/start-capture-artifacts.sh /opt/
ln -s $HOME/tools/appium/files/stop-capture-artifacts.sh /opt/
ln -s $HOME/tools/appium/files/upload-artifacts.sh /opt/
```
* Install aws cli: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
* Configure aws using your s3 access and secret keys, region etc
```
aws configure
```

### Prepare WebDriverAgent.ipa file

You need an Apple Developer account to sign in and build **WebDriverAgent**.

1. Open **WebDriverAgent.xcodeproj** in Xcode.
2. Ensure a team is selected before building the application. To do this, go to *Targets* and select each target (one at a time). There should be a field for assigning team certificates to the target.
3. Remove your **WebDriverAgent** folder from *DerivedData* and run *Clean build folder* (just in case).
4. Build the application by selecting the *WebDriverAgentRunner* target and build for *Generic iOS Device*. Run *Product -> Build for testing*. This will create a *Products/Debug-iphoneos* in the specified project directory.
*Example*: **/Users/$USER/Library/Developer/Xcode/DerivedData/WebDriverAgent-dzxbpamuepiwamhdbyvyfkbecyer/Build/Products/Debug-iphoneos**
5. Go to the "Products/Debug-iphoneos" directory and run:
**mkdir Payload**
6. Copy the WebDriverAgentRunner-Runner.app to the Payload directory:
**cp -r WebDriverAgentRunner-Runner.app Payload**
7. Finally, zip up the project as an *.ipa file:
**zip -r WebDriverAgent.ipa ./Payload**
> Make sure to specify relative `./Payload` to archive only Payload folder content
8. Get the WebDriverAgent.ipa file and put it onto the mcloud-ios host

## iOS-agent setup
* Clone mcloud-ios repo
Expand All @@ -45,43 +85,21 @@ Phone_X1 | 7643aa9bd1638255f48ca6beac4285cae4f6454g | 4842 | 20011 | 200

> Specify unique port numbers per each service. Those ports should be accessible from MCloud master host
* Reboot physical device and connect to your MacOS server.

* Execute setup procedure
```
./zebrunner.sh setup
```

* Provide the required arguments during the setup

* <b>Important!</b> Everytime you create new Simulator(s) via XCode, you have to add a new line into devices.txt to whitelist and run `authorize-simulator` command to authorize
```
./zebrunner.sh authorize-simulator
```
> It is enough to run `./zebrunner.sh authorize-simulator` command at once after generating multiple simulators
* <b>Important!</b> Everytime you create new Simulator(s) via XCode, you have to add a new line into devices.txt to whitelist and repeat `./zebrunner.sh setup` command to authorize.
> It is enough to execute setup command at once after generating multiple simulators
* Setup user [auto-login](https://support.apple.com/en-us/HT201476) for your current user to enable LaunchAgents loading on reboot

### Patch appium to enable video recordings
* Clone Zebrunner Appium and patch sources:
```
git clone https://github.com/zebrunner/appium.git
cd appium
export APPIUM_HOME=/usr/local/lib/node_modules/appium
cp -R -v ./files/mcloud/* ${APPIUM_HOME}
```
* Generate symlinks to shell scripts:
```
ln -s $HOME/tools/appium/files/concat-video-recordings.sh /opt/
ln -s $HOME/tools/appium/files/reset-logs.sh /opt/
ln -s $HOME/tools/appium/files/start-capture-artifacts.sh /opt/
ln -s $HOME/tools/appium/files/stop-capture-artifacts.sh /opt/
ln -s $HOME/tools/appium/files/upload-artifacts.sh /opt/
```
* Install aws cli: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
* Configure aws using your s3 access and secret keys, region etc
```
aws configure
```
* Restart services using `./zebrunner.sh restart`
* Execute `./zebrunner.sh` to see all available actions

## Documentation and free support
* [Zebrunner PRO](https://zebrunner.com)
Expand Down
1 change: 1 addition & 0 deletions backup/settings.env.original
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ ZBR_MCLOUD_PORT=80
ZBR_MCLOUD_NODE_HOSTNAME=
ZBR_MCLOUD_NODE_NAME=mcloud-ios
ZBR_MCLOUD_APPIUM_PATH=/usr/local/lib/node_modules/appium
ZBR_MCLOUD_WDA_PATH=./WebDriverAgent.ipa

8 changes: 5 additions & 3 deletions configs/getDeviceArgs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ if [ -z $proxy_port ]; then
export proxy_port=9000
fi

export APPIUM_LOG="logs/appium_${name}.log"
export STF_LOG="logs/stf_${name}.log"
export WDA_LOG="logs/wda_${name}.log"
export DEVICE_LOG="logs/${name}.log"

export WDA_ENV="${metaDataFolder}/${name}.env"
if [ -f "${WDA_ENV}" ]; then
. ${WDA_ENV}
fi

#reset to generate new value per udid
export physical=
export simulator=


export physical=`cat ${connectedDevices} | grep $udid`
#echo physical: $physical
Expand Down
Loading

0 comments on commit f48657c

Please sign in to comment.