Skip to content

Commit

Permalink
fix(appium): update client and CI to appium v2 (#318)
Browse files Browse the repository at this point in the history
* fix(appium-helper): update server base path

* fix(appium-helper): update capabilities to use required vendor prefix

* fix(appium-helper): update readme to mention appium driver installation

* chore: update appium version in CI

* chore: remove deprecated husky lines

---------

Co-authored-by: Rafael Rollo <rafaelrollo92@gmail.com>
  • Loading branch information
Almouro and rafael-rollo authored Sep 30, 2024
1 parent ebf8639 commit bba3ca2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 36 deletions.
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 2 additions & 2 deletions examples/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test": "tsc && yarn test:e2e"
},
"dependencies": {
"@bam.tech/appium-helper": "^0.5.4",
"@perf-profiler/e2e": "^0.11.3"
"@bam.tech/appium-helper": "*",
"@perf-profiler/e2e": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ phases:
- echo "Navigate to test package directory"
- cd $DEVICEFARM_TEST_PACKAGE_PATH
- npm install *.tgz
- export APPIUM_VERSION=1.22.2
- avm $APPIUM_VERSION
- >-
ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium
/usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js
- npm install --global yarn
pre_test:
commands:
- echo "Start appium server"
- npx appium@2.11.4 driver install uiautomator2
- >-
appium --log-timestamp --default-capabilities "{\\"deviceName\\":
\\"$DEVICEFARM_DEVICE_NAME\\",
\\"platformName\\":\\"$DEVICEFARM_DEVICE_PLATFORM_NAME\\",\\"app\\":\\"$DEVICEFARM_APP_PATH\\",
\\"udid\\":\\"$DEVICEFARM_DEVICE_UDID\\",
\\"platformVersion\\":\\"$DEVICEFARM_DEVICE_OS_VERSION\\",\\"chromedriverExecutable\\":\\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE\\"}"
npx appium@2.11.4 --log-timestamp --default-capabilities
"{\\"appium:deviceName\\": \\"$DEVICEFARM_DEVICE_NAME\\",
\\"appium:platformName\\":\\"$DEVICEFARM_DEVICE_PLATFORM_NAME\\",\\"appium:app\\":\\"$DEVICEFARM_APP_PATH\\",
\\"appium:udid\\":\\"$DEVICEFARM_DEVICE_UDID\\",
\\"appium:platformVersion\\":\\"$DEVICEFARM_DEVICE_OS_VERSION\\",\\"appium:chromedriverExecutable\\":\\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE\\"}"
>> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 &
- |-
start_appium_timeout=0;
Expand All @@ -36,10 +32,10 @@ phases:
echo "appium server never started in 60 seconds. Exiting";
exit 1;
fi;
grep -i "Appium REST http interface listener started on 0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1;
grep -i "Appium REST http interface listener started on http://0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1;
if [ $? -eq 0 ];
then
echo "Appium REST http interface listener started on 0.0.0.0:4723";
echo "Appium REST http interface listener started on http://0.0.0.0:4723";
break;
else
echo "Waiting for appium server to start. Sleeping for 1 second";
Expand Down Expand Up @@ -72,20 +68,16 @@ phases:
- echo "Navigate to test package directory"
- cd $DEVICEFARM_TEST_PACKAGE_PATH
- npm install *.tgz
- export APPIUM_VERSION=1.22.2
- avm $APPIUM_VERSION
- >-
ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium
/usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js
pre_test:
commands:
- echo "Start appium server"
- npx appium@2.11.4 driver install uiautomator2
- >-
appium --log-timestamp --default-capabilities "{\\"deviceName\\":
\\"$DEVICEFARM_DEVICE_NAME\\",
\\"platformName\\":\\"$DEVICEFARM_DEVICE_PLATFORM_NAME\\",\\"app\\":\\"$DEVICEFARM_APP_PATH\\",
\\"udid\\":\\"$DEVICEFARM_DEVICE_UDID\\",
\\"platformVersion\\":\\"$DEVICEFARM_DEVICE_OS_VERSION\\",\\"chromedriverExecutable\\":\\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE\\"}"
npx appium@2.11.4 --log-timestamp --default-capabilities
"{\\"appium:deviceName\\": \\"$DEVICEFARM_DEVICE_NAME\\",
\\"appium:platformName\\":\\"$DEVICEFARM_DEVICE_PLATFORM_NAME\\",\\"appium:app\\":\\"$DEVICEFARM_APP_PATH\\",
\\"appium:udid\\":\\"$DEVICEFARM_DEVICE_UDID\\",
\\"appium:platformVersion\\":\\"$DEVICEFARM_DEVICE_OS_VERSION\\",\\"appium:chromedriverExecutable\\":\\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE\\"}"
>> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 &
- |-
start_appium_timeout=0;
Expand All @@ -96,10 +88,10 @@ phases:
echo "appium server never started in 60 seconds. Exiting";
exit 1;
fi;
grep -i "Appium REST http interface listener started on 0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1;
grep -i "Appium REST http interface listener started on http://0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1;
if [ $? -eq 0 ];
then
echo "Appium REST http interface listener started on 0.0.0.0:4723";
echo "Appium REST http interface listener started on http://0.0.0.0:4723";
break;
else
echo "Waiting for appium server to start. Sleeping for 1 second";
Expand Down
15 changes: 7 additions & 8 deletions packages/plugins/aws-device-farm/src/buildYmlSpec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import yaml from "js-yaml";

const APPIUM_VERSION = "2.11.4";

export const Commands = {
INSTALL_NODE: ["devicefarm-cli use node 18", "node -v"],
UNPACKAGE_TEST_PACKAGE: [
'echo "Navigate to test package directory"',
"cd $DEVICEFARM_TEST_PACKAGE_PATH",
"npm install *.tgz",
],
INSTALL_APPIUM: [
"export APPIUM_VERSION=1.22.2",
"avm $APPIUM_VERSION",
"ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium /usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js",
],
START_APPIUM: [
'echo "Start appium server"',
`appium --log-timestamp --default-capabilities "{\\"deviceName\\": \\"$DEVICEFARM_DEVICE_NAME\\", \\"platformName\\":\\"$DEVICEFARM_DEVICE_PLATFORM_NAME\\",\\"app\\":\\"$DEVICEFARM_APP_PATH\\", \\"udid\\":\\"$DEVICEFARM_DEVICE_UDID\\", \\"platformVersion\\":\\"$DEVICEFARM_DEVICE_OS_VERSION\\",\\"chromedriverExecutable\\":\\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE\\"}" >> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 &`,
`npx appium@${APPIUM_VERSION} driver install uiautomator2`,
`npx appium@${APPIUM_VERSION} --log-timestamp --default-capabilities "{\\"appium:deviceName\\": \\"$DEVICEFARM_DEVICE_NAME\\", \\"appium:platformName\\":\\"$DEVICEFARM_DEVICE_PLATFORM_NAME\\",\\"appium:app\\":\\"$DEVICEFARM_APP_PATH\\", \\"appium:udid\\":\\"$DEVICEFARM_DEVICE_UDID\\", \\"appium:platformVersion\\":\\"$DEVICEFARM_DEVICE_OS_VERSION\\",\\"appium:chromedriverExecutable\\":\\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE\\"}" >> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 &`,
`start_appium_timeout=0;
while [ true ];
do
Expand All @@ -22,10 +21,10 @@ do
echo "appium server never started in 60 seconds. Exiting";
exit 1;
fi;
grep -i "Appium REST http interface listener started on 0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1;
grep -i "Appium REST http interface listener started on http://0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1;
if [ $? -eq 0 ];
then
echo "Appium REST http interface listener started on 0.0.0.0:4723";
echo "Appium REST http interface listener started on http://0.0.0.0:4723";
break;
else
echo "Waiting for appium server to start. Sleeping for 1 second";
Expand Down
1 change: 0 additions & 1 deletion packages/plugins/aws-device-farm/src/createTestSpecFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const buildAppiumYmlSpec = (commands: {
installCommands: [
...Commands.INSTALL_NODE,
...Commands.UNPACKAGE_TEST_PACKAGE,
...Commands.INSTALL_APPIUM,
...(commands.installCommands || []),
],
preTestCommands: [...Commands.START_APPIUM, ...(commands.preTestCommands || [])],
Expand Down

0 comments on commit bba3ca2

Please sign in to comment.