From bba3ca297d2fc85c916a2036d4cbc70d7a02af4e Mon Sep 17 00:00:00 2001 From: Alexandre Moureaux Date: Mon, 30 Sep 2024 17:20:30 +0200 Subject: [PATCH] fix(appium): update client and CI to appium v2 (#318) * 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 --- .husky/pre-commit | 1 - examples/e2e/package.json | 4 +- .../__snapshots__/createTestSpecFile.ts.snap | 40 ++++++++----------- .../aws-device-farm/src/buildYmlSpec.ts | 15 ++++--- .../aws-device-farm/src/createTestSpecFile.ts | 1 - 5 files changed, 25 insertions(+), 36 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af2198..3b608ae6 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,3 @@ #!/bin/sh -. "$(dirname "$0")/_/husky.sh" npx lint-staged diff --git a/examples/e2e/package.json b/examples/e2e/package.json index b9b83f88..8544eecd 100644 --- a/examples/e2e/package.json +++ b/examples/e2e/package.json @@ -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": "*" } } diff --git a/packages/plugins/aws-device-farm/src/__tests__/__snapshots__/createTestSpecFile.ts.snap b/packages/plugins/aws-device-farm/src/__tests__/__snapshots__/createTestSpecFile.ts.snap index f59325c9..24055797 100644 --- a/packages/plugins/aws-device-farm/src/__tests__/__snapshots__/createTestSpecFile.ts.snap +++ b/packages/plugins/aws-device-farm/src/__tests__/__snapshots__/createTestSpecFile.ts.snap @@ -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; @@ -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"; @@ -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; @@ -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"; diff --git a/packages/plugins/aws-device-farm/src/buildYmlSpec.ts b/packages/plugins/aws-device-farm/src/buildYmlSpec.ts index 8374c248..29a4800e 100644 --- a/packages/plugins/aws-device-farm/src/buildYmlSpec.ts +++ b/packages/plugins/aws-device-farm/src/buildYmlSpec.ts @@ -1,4 +1,7 @@ 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: [ @@ -6,14 +9,10 @@ export const Commands = { "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 @@ -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"; diff --git a/packages/plugins/aws-device-farm/src/createTestSpecFile.ts b/packages/plugins/aws-device-farm/src/createTestSpecFile.ts index b31c4ad5..ad5c914a 100644 --- a/packages/plugins/aws-device-farm/src/createTestSpecFile.ts +++ b/packages/plugins/aws-device-farm/src/createTestSpecFile.ts @@ -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 || [])],