diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..ace2af1 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,135 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. +# See: https://circleci.com/docs/configuration-reference + +# For a detailed guide to building and testing on iOS, read the docs: +# https://circleci.com/docs/testing-ios/ +on: + pull_request: + types: [opened, reopened] +version: 2.1 + +# Define a job to be invoked later in a workflow. +# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs +jobs: + WDIO_IOS: + # Specify the execution environment. + # See: https://circleci.com/docs/executor-intro/ & https://circleci.com/docs/configuration-reference/#executor-job + macos: + # Specify the Xcode version you desire here + # See: https://circleci.com/docs/using-macos/ + xcode: 15.2.0 + + # See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps + steps: + # Checkout the code as the first step. + - checkout + - run: xcrun simctl list devices available + - run: + name: Node Version + command: | + nvm install v22.2.0 && nvm alias default 22.2.0 + - run: + name: Install Appium and Run iOS Test + command: | + release_info=$(curl -s https://api.github.com/repos/AppiumTestDistribution/appium-flutter-server/releases/latest) + asset_urls=$(echo "$release_info" | grep "browser_download_url" | cut -d '"' -f 4) + ios_app=$(echo "$asset_urls" | tail -n 1) + echo "$ios_app" + curl -LO $ios_app + echo 'export APP_PATH=$CIRCLE_WORKING_DIRECTORY/ios.zip' >> $BASH_ENV + echo $pwd + echo ls + nvm install v22.2.0 && nvm alias default 22.2.0 + node -v + target_sim_id=$(xcrun simctl list devices available | grep "iPhone 14" | cut -d "(" -f2 | cut -d ")" -f1 | head -n 1) + echo $target_sim_id + echo 'export UDID=$target_sim_id' >> $BASH_ENV + xcrun simctl boot $target_sim_id + xcrun simctl bootstatus $target_sim_id -b + npm install -g appium@2.19.0 + npm run build-flutter-by-service + npm install --no-package-lock + npm run build + appium driver list + appium driver run xcuitest build-wda + wda=$(ls -d /Users/distiller/Library/Developer/Xcode/DerivedData/WebDriverAgent*) + echo $wda + echo 'export WDA_PATH=$wda' >> $BASH_ENV + echo ${WDA_PATH} + echo ${PROJECT_ENV_VAR} + xcrun simctl install $target_sim_id $wda/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app + xcrun simctl launch $target_sim_id "com.facebook.WebDriverAgentRunner.xctrunner" + mkdir appium-logs + UDID=$target_sim_id APP_PATH=$ios_app npm run wdio-ios + + - store_artifacts: + path: appium-logs +# JAVA_IOS: +# # Specify the execution environment. +# # See: https://circleci.com/docs/executor-intro/ & https://circleci.com/docs/configuration-reference/#executor-job +# # Add steps to the job +# # See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps +# macos: +# # Specify the Xcode version you desire here +# # See: https://circleci.com/docs/using-macos/ +# xcode: 15.2.0 +# steps: +# # Checkout the code as the first step. +# - checkout +# - run: xcrun simctl list devices available +# - run: +# name: Node Version +# command: | +# nvm install v22.2.0 && nvm alias default 22.2.0 +# - run: +# name: Install Appium and Run iOS Test +# command: | +# release_info=$(curl -s https://api.github.com/repos/AppiumTestDistribution/appium-flutter-server/releases/latest) +# asset_urls=$(echo "$release_info" | grep "browser_download_url" | cut -d '"' -f 4) +# ios_app=$(echo "$asset_urls" | tail -n 1) +# echo "$ios_app" +# curl -LO $ios_app +# echo 'export APP_PATH=$CIRCLE_WORKING_DIRECTORY/ios.zip' >> $BASH_ENV +# echo $APP_PATH +# nvm install v22.2.0 && nvm alias default 22.2.0 +# node -v +# target_sim_id=$(xcrun simctl list devices available | grep "iPhone 14" | cut -d "(" -f2 | cut -d ")" -f1 | head -n 1) +# echo $target_sim_id +# echo 'export UDID=$target_sim_id' >> $BASH_ENV +# xcrun simctl boot $target_sim_id +# xcrun simctl bootstatus $target_sim_id -b +# npm install -g appium@2.19.0 +# npm install --no-package-lock +# npm run build +# appium driver list +# appium driver run xcuitest build-wda +# wda=$(ls -d /Users/distiller/Library/Developer/Xcode/DerivedData/WebDriverAgent*) +# echo $wda +# echo 'export WDA_PATH=$wda' >> $BASH_ENV +# echo ${WDA_PATH} +# echo ${PROJECT_ENV_VAR} +# xcrun simctl install $target_sim_id $wda/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app +# xcrun simctl launch $target_sim_id "com.facebook.WebDriverAgentRunner.xctrunner" +# mkdir appium-logs +# git clone https://github.com/AppiumTestDistribution/flutter-finder.git +# cd flutter-finder/flutter-by/java +# UDID=$target_sim_id APP_PATH=$ios_app Platform=ios ./gradlew clean test --debug + +# - store_artifacts: +# path: flutter-finder/flutter-by/java/appium.log +# # Orchestrate jobs using workflows +# # See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows +workflows: + ios: # This is the name of the workflow, feel free to change it to better match your workflow. + # Inside the workflow, you define the jobs you want to run. + jobs: + - WDIO_IOS: + filters: + branches: + ignore: + - main + # - JAVA_IOS: + # filters: + # branches: + # ignore: + # - main diff --git a/.github/workflows/appium3_ios.yml b/.github/workflows/appium3_ios.yml deleted file mode 100644 index f9cc41c..0000000 --- a/.github/workflows/appium3_ios.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: iOS WDIO Tests with Appium 3 - -on: - pull_request: - -env: - CI: true - SHOW_XCODE_LOG: true - PREBUILT_WDA_PATH: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app - -jobs: - wdio_ios: - runs-on: macos-26 - name: WDIO iOS (Xcode 16.4) - steps: - - uses: actions/checkout@v4 - - - name: Install Node.js 22.x - uses: actions/setup-node@v3 - with: - node-version: '22.x' - - - name: Select Xcode 16.4 - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '16.4' - - - name: List Installed Simulators - run: xcrun simctl list devices available - - name: Install jq - run: brew install jq - - - run: | - version=$(grep 'appium_flutter_server:' README.md | awk '{print $2}') - ios_app="https://github.com/AppiumTestDistribution/appium-flutter-server/releases/download/$version/ios.zip" - echo "Downloading from: $ios_app" - curl -LO "$ios_app" - echo "APP_PATH=$(pwd)/ios.zip" >> $GITHUB_ENV - name: Download sample iOS app - - - name: Start iOS Simulator UI - run: open -Fn "$(xcode-select --print-path)/Applications/Simulator.app" - - - name: Boot simulator - id: prepareSimulator - uses: futureware-tech/simulator-action@v4 - with: - model: 'iPhone 16' - os_version: '18.5' - shutdown_after_job: false - wait_for_boot: true - - - run: | - target_sim_id=$(xcrun simctl list devices available | grep -A 10 "Booted" | cut -d "(" -f2 | cut -d ")" -f1 | head -n 1) - echo "Target sim id: $target_sim_id" - echo "udid=$target_sim_id" >> $GITHUB_ENV - - - run: | - npm install -g appium - npm install --no-package-lock - npm run build-flutter-by-service - npm run build - name: Install Appium and deps - - - run: | - appium driver list - appium driver doctor xcuitest - appium driver run xcuitest download-wda-sim --platform=ios --outdir=$(dirname "$PREBUILT_WDA_PATH") - echo "WDA path: $PREBUILT_WDA_PATH" - echo "WDA_PATH=$PREBUILT_WDA_PATH" >> $GITHUB_ENV - name: Build WDA with XCUITest driver - - - run: | - echo "UDID: $udid" - echo "WDA path: $PREBUILT_WDA_PATH" - xcrun simctl install $udid $PREBUILT_WDA_PATH - xcrun simctl launch $udid "com.facebook.WebDriverAgentRunner.xctrunner" - name: Install and launch WDA on Simulator - - - run: | - mkdir -p appium-logs - UDID=$udid APP_PATH=$APP_PATH npm run wdio-ios | tee appium-logs/logs.txt - name: Run WDIO iOS - - - - name: Upload logs - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - name: appium-logs - path: appium-logs diff --git a/.github/workflows/appium3._android.yml b/.github/workflows/main.yml similarity index 91% rename from .github/workflows/appium3._android.yml rename to .github/workflows/main.yml index 61f0535..9a0db1a 100644 --- a/.github/workflows/appium3._android.yml +++ b/.github/workflows/main.yml @@ -1,11 +1,7 @@ -name: Appium Flutter Integration Driver with Appium 3 - on: - pull_request: - -env: - CI: true + pull_request: +name: Appium Flutter Integration Driver jobs: Android_E2E_WDIO: runs-on: ubuntu-latest @@ -26,15 +22,18 @@ jobs: - name: 'List files' run: | - version=$(grep 'appium_flutter_server:' README.md | awk '{print $2}') - android_app="https://github.com/AppiumTestDistribution/appium-flutter-server/releases/download/$version/app-debug.apk" + release_info=$(curl -s https://api.github.com/repos/AppiumTestDistribution/appium-flutter-server/releases/latest) + asset_urls=$(echo "$release_info" | grep "browser_download_url" | cut -d '"' -f 4) + android_app=$(echo "$asset_urls" | head -n 1) echo "$android_app" + ios_app=$(echo "$asset_urls" | tail -n 1) + echo "$ios_app" curl -LO $android_app ls ${{ github.workspace }} echo "APP_PATH=${{ github.workspace }}/app-debug.apk" >> $GITHUB_ENV - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 20 - name: Enable KVM group perms run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules @@ -50,7 +49,7 @@ jobs: npm run build - name: Install Drivers run: | - npm install -g appium + npm install -g appium@2.19.0 appium driver list - name: run tests uses: reactivecircus/android-emulator-runner@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d0d2a24..891a285 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 20 - run: npm install --no-package-lock name: Install dependencies - run: npm run build diff --git a/package.json b/package.json index 8dbd5af..fced9b2 100644 --- a/package.json +++ b/package.json @@ -90,14 +90,14 @@ "webdriverio": "9.19.2" }, "peerDependencies": { - "appium": "^3.0.0" + "appium": "^2.5.4" }, "dependencies": { - "@appium/base-driver": "^10.0.0", - "appium-adb": "^13.0.0", - "appium-ios-device": "^3.0.0", - "appium-uiautomator2-driver": "^5.0.0", - "appium-xcuitest-driver": "^10.0.0", + "@appium/base-driver": "^9.16.4", + "appium-adb": "^12.4.4", + "appium-ios-device": "^2.7.20", + "appium-uiautomator2-driver": "^4.1.5", + "appium-xcuitest-driver": "9.1.2", "async-retry": "^1.3.3", "asyncbox": "^3.0.0", "bluebird": "^3.7.2", diff --git a/src/driver.ts b/src/driver.ts index 336e9fe..41f057d 100644 --- a/src/driver.ts +++ b/src/driver.ts @@ -465,7 +465,7 @@ export class AppiumFlutterDriver extends BaseDriver { // @ts-ignore await this.proxydriver.adb.removePortForward(this.flutterPort); } - await this.proxydriver?.deleteSession(this.sessionId); + await this.proxydriver?.deleteSession(); await super.deleteSession(); } diff --git a/src/iOS.ts b/src/iOS.ts index f746295..80ffd01 100644 --- a/src/iOS.ts +++ b/src/iOS.ts @@ -1,16 +1,16 @@ import type { AppiumFlutterDriver } from './driver'; // @ts-ignore import { XCUITestDriver } from 'appium-xcuitest-driver'; +import type { InitialOpts } from '@appium/types'; import { DEVICE_CONNECTIONS_FACTORY } from './iProxy'; -import { XCUITestDriverOpts } from 'appium-xcuitest-driver/build/lib/driver'; export async function startIOSSession( this: AppiumFlutterDriver, ...args: any[] ): Promise { this.log.info(`Starting an IOS proxy session`); - const iosdriver = new XCUITestDriver({} as XCUITestDriverOpts); - await iosdriver.createSession.apply(iosdriver, args); + const iosdriver = new XCUITestDriver({} as InitialOpts); + await iosdriver.createSession(...args); return iosdriver; } diff --git a/wdio.conf.ts b/wdio.conf.ts index 9b2e3a1..bf7fc09 100644 --- a/wdio.conf.ts +++ b/wdio.conf.ts @@ -126,7 +126,7 @@ export const config: Options.Testrunner = { basePath: '/wd/hub', port: 4723, log: join(process.cwd(), 'appium-logs', 'logs.txt'), - allowInsecure: '*:chromedriver_autodownload,*:adb_shell', + allowInsecure: 'chromedriver_autodownload,adb_shell', }, }, ],