diff --git a/.circleci/config.yml b/.circleci/config.yml index 0994fba..a6eeeff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,7 +46,7 @@ jobs: 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 + npm install -g appium@2.19.0 npm ci npm run build appium driver run xcuitest build-wda @@ -97,7 +97,7 @@ jobs: 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 + npm install -g appium@2.19.0 npm ci npm run build appium driver run xcuitest build-wda diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bdb2c84..f0c52db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,7 @@ jobs: npm run build - name: Install Drivers run: | - npm install -g appium + npm install -g appium@2.19.0 appium driver list - name: Checkout Test from Flutter Finder uses: actions/checkout@v2 @@ -125,7 +125,7 @@ jobs: npm run build - name: Install Drivers run: | - npm install -g appium + npm install -g appium@2.19.0 appium driver list - name: Checkout Test from Flutter Finder uses: actions/checkout@v2 diff --git a/package-lock.json b/package-lock.json index 6e797bf..ed98dc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "appium-flutter-integration-driver", - "version": "1.1.3", + "version": "1.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "appium-flutter-integration-driver", - "version": "1.1.3", + "version": "1.3.0", "license": "MIT License", "dependencies": { "@appium/base-driver": "^9.16.4", diff --git a/src/commands/element.ts b/src/commands/element.ts index 8b14cbd..b648940 100644 --- a/src/commands/element.ts +++ b/src/commands/element.ts @@ -56,6 +56,14 @@ export async function getText(this: AppiumFlutterDriver, elementId: string) { return String(await driver.command(`/element/${elementId}/text`, 'GET', {})); } +export async function getElementRect( + this: AppiumFlutterDriver, + elementId: string, +) { + const driver = ELEMENT_CACHE.get(elementId); + return await driver.command(`/element/${elementId}/rect`, 'GET', {}); +} + export async function elementEnabled( this: AppiumFlutterDriver, elementId: string, diff --git a/src/driver.ts b/src/driver.ts index bcc6aef..a91ea3f 100644 --- a/src/driver.ts +++ b/src/driver.ts @@ -21,6 +21,7 @@ import { setValue, clear, ELEMENT_CACHE, + getElementRect, } from './commands/element'; import { attachAppLaunchArguments, @@ -65,6 +66,7 @@ export class AppiumFlutterDriver extends BaseDriver { findElOrEls = findElOrEls; getText = getText; getAttribute = getAttribute; + getElementRect = getElementRect; elementDisplayed = elementDisplayed; elementEnabled = elementEnabled; setValue = setValue; @@ -217,6 +219,10 @@ export class AppiumFlutterDriver extends BaseDriver { isFlutterDriverCommand(command) ) { return await super.executeCommand(command, ...args); + } else { + this.log.info( + `Executing the command: ${command} with args: ${args} and flutterCommand ${isFlutterDriverCommand(command)}`, + ); } this.handleContextSwitch(command, args); diff --git a/src/utils.ts b/src/utils.ts index 22394e5..aeb0f09 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -61,6 +61,8 @@ export function isFlutterDriverCommand(command: string) { 'getAttribute', 'elementDisplayed', 'execute', + 'getElementRect', + 'getSize', ].indexOf(command) >= 0 ); } diff --git a/test/specs/test.e2e.js b/test/specs/test.e2e.js index 6408b08..1b46d2f 100644 --- a/test/specs/test.e2e.js +++ b/test/specs/test.e2e.js @@ -67,6 +67,9 @@ describe('My Login application', () => { .flutterByValueKey$('double_tap_button') .flutterByText$('Double Tap'); expect(await element.getText()).toEqual('Double Tap'); + const size = await element.getSize(); + expect(size.width).toBeGreaterThan(0); + expect(size.height).toBeGreaterThan(0); await browser.flutterDoubleClick({ element: element, }); @@ -101,6 +104,19 @@ describe('My Login application', () => { expect(await message.getText()).toEqual('Hello world'); }); + it.only('Nested Scroll Test', async () => { + await performLogin(); + await openScreen('Nested Scroll'); + const parentElement = await browser.flutterScrollTillVisible({ + finder: await browser.flutterByText('Parent Element 4'), + scrollDirection: 'down', + }); + await browser.flutterScrollTillVisible({ + finder: await parentElement.flutterByValueKey(''), + scrollView: parentElement, + scrollDirection: 'down', + }); + }); it('Scroll Test', async () => { await performLogin(); await openScreen('Vertical Swiping'); diff --git a/test/unit/element.specs.ts b/test/unit/element.specs.ts index 6b90c42..04c7da9 100644 --- a/test/unit/element.specs.ts +++ b/test/unit/element.specs.ts @@ -11,6 +11,7 @@ import { elementEnabled, findElOrEls, getAttribute, + getElementRect, getText, setValue, } from '../../src/commands/element'; @@ -186,6 +187,32 @@ describe('Element Interaction Functions', () => { }); }); + describe('getRect', () => { + it('should get rect from an element correctly', async () => { + const elementId = 'elem1'; + ELEMENT_CACHE.set(elementId, mockDriver); + mockDriver.command.resolves( + '{"x": 10, "y": 20, "width": 100, "height": 50}', + ); + + const result = await getElementRect.call( + mockAppiumFlutterDriver, + elementId, + ); + + expect(result).to.equal( + '{"x": 10, "y": 20, "width": 100, "height": 50}', + ); + expect( + mockDriver.command.calledWith( + `/element/${elementId}/rect`, + 'GET', + {}, + ), + ).to.be.true; + }); + }); + describe('getAttribute', () => { it('should get an attribute from an element correctly', async () => { const elementId = 'elem1'; diff --git a/wdio.conf.ts b/wdio.conf.ts index 17324db..814fee9 100644 --- a/wdio.conf.ts +++ b/wdio.conf.ts @@ -142,7 +142,7 @@ export const config: Options.Testrunner = { // // The number of times to retry the entire specfile when it fails as a whole - specFileRetries: 1, + specFileRetries: 0, // // Delay in seconds between the spec file retry attempts // specFileRetriesDelay: 0,