From e3f31202ebc774a23c55a339118b96614c16dc47 Mon Sep 17 00:00:00 2001 From: saikrishna321 Date: Wed, 24 Sep 2025 16:29:17 +0530 Subject: [PATCH 1/4] Added Initial ci for mac apps Co-authored-by: SrinivasanTarget --- .github/workflows/appium3._android.yml | 1 + .github/workflows/appium3_ios.yml | 1 + .github/workflows/appium3_macos.yml | 51 ++++++++++++++++++++++++++ mac.conf.ts | 19 ++++++++++ package.json | 3 +- src/driver.ts | 38 ++++++++++--------- 6 files changed, 94 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/appium3_macos.yml create mode 100644 mac.conf.ts diff --git a/.github/workflows/appium3._android.yml b/.github/workflows/appium3._android.yml index 61f0535..7860c8c 100644 --- a/.github/workflows/appium3._android.yml +++ b/.github/workflows/appium3._android.yml @@ -8,6 +8,7 @@ env: jobs: Android_E2E_WDIO: + if: ${{ false }} runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/appium3_ios.yml b/.github/workflows/appium3_ios.yml index f9cc41c..ec2c20b 100644 --- a/.github/workflows/appium3_ios.yml +++ b/.github/workflows/appium3_ios.yml @@ -10,6 +10,7 @@ env: jobs: wdio_ios: + if: ${{ false }} runs-on: macos-26 name: WDIO iOS (Xcode 16.4) steps: diff --git a/.github/workflows/appium3_macos.yml b/.github/workflows/appium3_macos.yml new file mode 100644 index 0000000..852923e --- /dev/null +++ b/.github/workflows/appium3_macos.yml @@ -0,0 +1,51 @@ +name: macOS WDIO Tests with Appium 3 + +on: + pull_request: + +env: + CI: true + SHOW_XCODE_LOG: true + +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/macos.zip" + echo "Downloading from: $ios_app" + curl -LO "$ios_app" + unzip -o macos.zip + ls -l + echo "APP_PATH=$(pwd)/appium_testing_app.app" >> $GITHUB_ENV + echo $APP_PATH + name: Download sample iOS app + + - name: Boot simulator + run: open -Fn $APP_PATH + + - run: | + npm install -g appium + npm install --no-package-lock + npm run build-flutter-by-service + npm run build + name: Install Appium and deps diff --git a/mac.conf.ts b/mac.conf.ts new file mode 100644 index 0000000..77cbdd6 --- /dev/null +++ b/mac.conf.ts @@ -0,0 +1,19 @@ +//@ts-nocheck +import { config as baseConfig } from './wdio.conf.ts'; + +export const config: WebdriverIO.Config = { + ...baseConfig, + capabilities: [ + { + // capabilities for local Appium web tests on an Android Emulator + platformName: 'mac', + 'appium:automationName': 'FlutterIntegration', + 'appium:orientation': 'PORTRAIT', + 'appium:app': "/Users/saikrishna/Documents/git/appium-flutter-server/demo-app/build/macos/Build/Products/Debug/appium_testing_app.app", + 'appium:bundleId': "com.example.appiumTestingApp", + 'appium:newCommandTimeout': 240, + 'appium:flutterServerLaunchTimeout': 25000, + 'appium:flutterEnableMockCamera': true + }, + ], +}; diff --git a/package.json b/package.json index 94173ae..fdfa409 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "reinstall-driver": "(appium driver uninstall flutter-integration || exit 0) && npm run install-driver", "wdio-android": "wdio run ./android.conf.ts", "wdio-ios": "wdio run ./ios.conf.ts", + "wdio-mac": "wdio run ./mac.conf.ts", "build-flutter-by-service": "cd ./flutter-finder/wdio-flutter-by-service && npm install --no-package-lock && npm run build" }, "devDependencies": { @@ -73,6 +74,7 @@ "@wdio/spec-reporter": "^9.19.2", "@wdio/types": "9.19.2", "@wdio/utils": "^9.19.2", + "appium-mac2-driver": "^3.0.0", "chai": "^5.1.1", "chai-as-promised": "^8.0.0", "conventional-changelog-conventionalcommits": "^8.0.0", @@ -99,7 +101,6 @@ "appium-ios-device": "^3.0.0", "appium-uiautomator2-driver": "^5.0.0", "appium-xcuitest-driver": "^10.0.0", - "appium-mac2-driver": "^3.0.0", "async-retry": "^1.3.3", "asyncbox": "^3.0.0", "bluebird": "^3.7.2", diff --git a/src/driver.ts b/src/driver.ts index 5197d7e..188484d 100644 --- a/src/driver.ts +++ b/src/driver.ts @@ -1,31 +1,36 @@ -import { desiredCapConstraints } from './desiredCaps'; -import { JWProxy, BaseDriver } from '@appium/base-driver'; +import { BaseDriver, JWProxy } from '@appium/base-driver'; import type { DefaultCreateSessionResult, + DriverCaps, DriverData, W3CDriverCaps, - DriverCaps, } from '@appium/types'; +import { desiredCapConstraints } from './desiredCaps'; type FlutterDriverConstraints = typeof desiredCapConstraints; // @ts-ignore -import { XCUITestDriver } from 'appium-xcuitest-driver'; import { AndroidUiautomator2Driver } from 'appium-uiautomator2-driver'; +import { XCUITestDriver } from 'appium-xcuitest-driver'; // @ts-ignore import { Mac2Driver } from 'appium-mac2-driver'; -import { createSession as createSessionMixin } from './session'; +import { logger, util } from 'appium/support'; +import _ from 'lodash'; +import { androidPortForward, androidRemovePortForward } from './android'; import { - findElOrEls, + clear, click, - getText, + ELEMENT_CACHE, elementDisplayed, - getAttribute, elementEnabled, - setValue, - clear, - ELEMENT_CACHE, + findElOrEls, + getAttribute, getElementRect, + getText, + setValue, constructFindElementPayload, } from './commands/element'; +import { iosPortForward, iosRemovePortForward } from './iOS'; +import { createSession as createSessionMixin } from './session'; +import type { PortForwardCallback, PortReleaseCallback } from './types'; import { attachAppLaunchArguments, fetchFlutterServerPort, @@ -34,11 +39,6 @@ import { isFlutterDriverCommand, waitForFlutterServerToBeActive, } from './utils'; -import { logger, util } from 'appium/support'; -import { androidPortForward, androidRemovePortForward } from './android'; -import { iosPortForward, iosRemovePortForward } from './iOS'; -import type { PortForwardCallback, PortReleaseCallback } from './types'; -import _ from 'lodash'; import type { RouteMatcher } from '@appium/types'; @@ -289,14 +289,16 @@ export class AppiumFlutterDriver extends BaseDriver { caps, ...JSON.parse(JSON.stringify(args)), ); + console.info(`proxydriver: ${JSON.stringify(this.proxydriver)}`); const packageName = this.proxydriver instanceof AndroidUiautomator2Driver ? this.proxydriver.opts.appPackage! : this.proxydriver.opts.bundleId!; const isIosSimulator = - this.proxydriver instanceof XCUITestDriver && - !this.proxydriver.isRealDevice(); + (this.proxydriver instanceof XCUITestDriver && + !this.proxydriver.isRealDevice()) || + this.proxydriver instanceof Mac2Driver; const portcallbacks: { portForwardCallback?: PortForwardCallback; From 2856751fd65d31ad00d9cc9ecfce0167b8b06225 Mon Sep 17 00:00:00 2001 From: saikrishna321 Date: Wed, 24 Sep 2025 16:59:37 +0530 Subject: [PATCH 2/4] Run test Co-authored-by: SrinivasanTarget --- .github/workflows/appium3_macos.yml | 4 ++++ mac.conf.ts | 2 +- test/specs/test.e2e.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/appium3_macos.yml b/.github/workflows/appium3_macos.yml index 852923e..aa8e931 100644 --- a/.github/workflows/appium3_macos.yml +++ b/.github/workflows/appium3_macos.yml @@ -48,4 +48,8 @@ jobs: npm install --no-package-lock npm run build-flutter-by-service npm run build + appium driver list name: Install Appium and deps + - run: | + APP_PATH=$APP_PATH npm run wdio-macos + name: Run WDIO macOS \ No newline at end of file diff --git a/mac.conf.ts b/mac.conf.ts index 77cbdd6..907083f 100644 --- a/mac.conf.ts +++ b/mac.conf.ts @@ -9,7 +9,7 @@ export const config: WebdriverIO.Config = { platformName: 'mac', 'appium:automationName': 'FlutterIntegration', 'appium:orientation': 'PORTRAIT', - 'appium:app': "/Users/saikrishna/Documents/git/appium-flutter-server/demo-app/build/macos/Build/Products/Debug/appium_testing_app.app", + 'appium:app': process.env.APP_PATH, 'appium:bundleId': "com.example.appiumTestingApp", 'appium:newCommandTimeout': 240, 'appium:flutterServerLaunchTimeout': 25000, diff --git a/test/specs/test.e2e.js b/test/specs/test.e2e.js index aa95e5f..b656dc0 100644 --- a/test/specs/test.e2e.js +++ b/test/specs/test.e2e.js @@ -73,7 +73,7 @@ describe('My Login application', () => { await handleAppManagement(); }); - it('Create Session with Flutter Integration Driver', async () => { + it.only('Create Session with Flutter Integration Driver', async () => { await performLogin(); await openScreen('Double Tap'); const element = await browser From 4ec76641ce97fdb4b4710f79f0aab998958003b6 Mon Sep 17 00:00:00 2001 From: saikrishna321 Date: Wed, 24 Sep 2025 17:21:21 +0530 Subject: [PATCH 3/4] Fix run command Co-authored-by: SrinivasanTarget --- .github/workflows/appium3_macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/appium3_macos.yml b/.github/workflows/appium3_macos.yml index aa8e931..5ee446e 100644 --- a/.github/workflows/appium3_macos.yml +++ b/.github/workflows/appium3_macos.yml @@ -51,5 +51,5 @@ jobs: appium driver list name: Install Appium and deps - run: | - APP_PATH=$APP_PATH npm run wdio-macos + APP_PATH=$APP_PATH npm run wdio-mac name: Run WDIO macOS \ No newline at end of file From 60d30f12a7cb34135b09bb1a8411123443485bde Mon Sep 17 00:00:00 2001 From: sudharsan-selvaraj Date: Thu, 9 Oct 2025 16:43:51 +0530 Subject: [PATCH 4/4] remove screenshot --- .../wdio-flutter-by-service/test_remove/specs/test.e2e.js | 2 +- test/specs/test.e2e.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flutter-finder/wdio-flutter-by-service/test_remove/specs/test.e2e.js b/flutter-finder/wdio-flutter-by-service/test_remove/specs/test.e2e.js index 3f116da..1a11d9a 100644 --- a/flutter-finder/wdio-flutter-by-service/test_remove/specs/test.e2e.js +++ b/flutter-finder/wdio-flutter-by-service/test_remove/specs/test.e2e.js @@ -2,7 +2,7 @@ import { browser, expect } from '@wdio/globals'; import path from "path"; async function performLogin(userName = 'admin', password = '1234') { - await browser.takeScreenshot(); + // await browser.takeScreenshot(); const att = await browser.flutterByValueKey$('username_text_field'); console.log(await att.getAttribute('all')); await browser.flutterByValueKey$('username_text_field').clearValue(); diff --git a/test/specs/test.e2e.js b/test/specs/test.e2e.js index b656dc0..49b8a14 100644 --- a/test/specs/test.e2e.js +++ b/test/specs/test.e2e.js @@ -2,7 +2,7 @@ import { browser, expect } from '@wdio/globals'; import path from 'path'; async function performLogin(userName = 'admin', password = '1234') { - await browser.takeScreenshot(); + // await browser.takeScreenshot(); const att = await browser.flutterByValueKey$('username_text_field'); console.log(await att.getAttribute('all')); await browser.flutterByValueKey$('username_text_field').clearValue();