Skip to content

Commit

Permalink
chore: update puppeteer adapter better timeout (#314)
Browse files Browse the repository at this point in the history
* Updat puppeteer adapter better timeout

* many more timeouts increase and make variable

* add prerelease script

* deploy dev function

* beta release please

* beta release

* also publish on pull-request

* oops found bug ha

* update snapshots

* remove lint stuff

* ignore commit lint

* remove IE11
  • Loading branch information
alfredwesterveld authored Apr 24, 2023
1 parent 8e83af7 commit 10dfb3e
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 126 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ name: 'Release'
on:
push:
branches: [master]

pull_request:
branches: [master]
jobs:
commitlint:
name: 'CommitLint'
runs-on: ubuntu-latest
# commitlint:
# name: 'CommitLint'
# runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
path: .
- uses: actions/setup-node@v3
with:
node-version: 16
- run: echo "::set-output name=dir::$(yarn cache dir)"
id: yarn-cache-dir
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: yarn-cache-12-${{ hashFiles('**/yarn.lock') }}
restore-keys: yarn-cache-12-
- run: bash ./scripts/ci/setup/default.sh
- run: bash ./scripts/ci/jobs/commitlint.sh
# steps:
# - uses: actions/checkout@v3
# with:
# path: .
# - uses: actions/setup-node@v3
# with:
# node-version: 16
# - run: echo "::set-output name=dir::$(yarn cache dir)"
# id: yarn-cache-dir
# - uses: actions/cache@v3
# with:
# path: ${{ steps.yarn-cache-dir.outputs.dir }}
# key: yarn-cache-12-${{ hashFiles('**/yarn.lock') }}
# restore-keys: yarn-cache-12-
# - run: bash ./scripts/ci/setup/default.sh
# - run: bash ./scripts/ci/jobs/commitlint.sh

release_packages:
name: 'Packages'
runs-on: ubuntu-latest
needs: [commitlint]

steps:
- uses: actions/checkout@v3
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/selenium_3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,3 @@ jobs:
with:
name: screenshots_selenium_3_edge
path: __artifacts__/jest/*.png

test_selenium_3_ie11:
name: 'IE11'
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
path: .
- uses: actions/setup-node@v3
with:
node-version: 16
- run: echo "::set-output name=dir::$(yarn cache dir)"
id: yarn-cache-dir
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: yarn-cache-12-${{ hashFiles('**/yarn.lock') }}
restore-keys: yarn-cache-12-
- run: bash ./scripts/ci/setup/default.sh
- run: bash ./scripts/ci/setup/ie11.sh
- run: bash ./scripts/ci/jobs/test_selenium_3_ie11.sh
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: screenshots_selenium_3_ie11
path: __artifacts__/jest/*.png
28 changes: 0 additions & 28 deletions .github/workflows/selenium_4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,3 @@ jobs:
with:
name: screenshots_selenium_4_edge
path: __artifacts__/jest/*.png

test_selenium_4_ie11:
name: 'IE11'
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
path: .
- uses: actions/setup-node@v3
with:
node-version: 16
- run: echo "::set-output name=dir::$(yarn cache dir)"
id: yarn-cache-dir
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: yarn-cache-12-${{ hashFiles('**/yarn.lock') }}
restore-keys: yarn-cache-12-
- run: bash ./scripts/ci/setup/default.sh
- run: bash ./scripts/ci/setup/ie11.sh
- run: bash ./scripts/ci/jobs/test_selenium_4_ie11.sh
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: screenshots_selenium_4_ie11
path: __artifacts__/jest/*.png
2 changes: 1 addition & 1 deletion __snapshots__/env_browser/adapter/clickAtElement.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adapter.clickAtElement throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" with filter [visible=true, onscreen=true] after 200ms"`;
exports[`adapter.clickAtElement throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" with filter [visible=true, onscreen=true] after 500ms"`;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adapter.clickAtElementCenter throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" with filter [visible=true, onscreen=true] after 200ms"`;
exports[`adapter.clickAtElementCenter throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" with filter [visible=true, onscreen=true] after 500ms"`;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adapter.getElementAttributes throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" after 200ms"`;
exports[`adapter.getElementAttributes throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" after 500ms"`;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adapter.getElementProperties throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" after 200ms"`;
exports[`adapter.getElementProperties throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" after 500ms"`;
2 changes: 1 addition & 1 deletion __snapshots__/env_browser/adapter/getElementStyles.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adapter.getElementStyles throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" after 200ms"`;
exports[`adapter.getElementStyles throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" after 500ms"`;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adapter.moveMouseToElement throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" with filter [visible=true, onscreen=true] after 200ms"`;
exports[`adapter.moveMouseToElement throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" with filter [visible=true, onscreen=true] after 500ms"`;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adapter.moveMouseToElementCenter throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" with filter [visible=true, onscreen=true] after 200ms"`;
exports[`adapter.moveMouseToElementCenter throws a valid error when an element cannot be found 1`] = `"Found no element for selector \\"#dullahan\\" with filter [visible=true, onscreen=true] after 500ms"`;
71 changes: 29 additions & 42 deletions packages/dullahan-adapter-puppeteer/src/DullahanAdapterPuppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
waitForReadyState
} from '@k2g/dullahan';

const findElementTimeout = 500;

export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAdapterPuppeteerUserOptions,
typeof DullahanAdapterPuppeteerDefaultOptions> {

Expand Down Expand Up @@ -71,7 +73,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand All @@ -98,7 +100,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: true,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -127,7 +129,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: true,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -156,7 +158,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: true,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -185,7 +187,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: true,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -267,7 +269,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -297,7 +299,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -334,7 +336,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand All @@ -361,7 +363,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand All @@ -388,7 +390,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -519,29 +521,14 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
if (!page) {
throw new AdapterError(DullahanErrorMessage.NO_BROWSER);
}

const findOptions: FindElementOptions = {
selector,
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: false,
timeout: 200,
promise: true,
expectNoMatches: false
};

const elementHandle = await page.evaluateHandle(findElement, findOptions);
const element = elementHandle.asElement();

if (!element) {
throw new AdapterError(DullahanErrorMessage.findElementResult(findOptions));
}

if (useTouch) {
return element.tap();
const element = await page.$(selector);
element?.tap();
return page.tap(selector);
}

await element.click({ button });
await page.click(selector, {
button
});
}

public async clickAt(x: number, y: number): Promise<void> {
Expand Down Expand Up @@ -570,7 +557,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: true,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -605,7 +592,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -663,7 +650,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand All @@ -690,7 +677,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -725,7 +712,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -768,7 +755,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand All @@ -791,7 +778,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand All @@ -814,7 +801,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: true,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -847,7 +834,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: true,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -876,7 +863,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: true,
onScreenOnly: true,
interactiveOnly: true,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down Expand Up @@ -972,7 +959,7 @@ export default class DullahanAdapterPuppeteer extends DullahanAdapter<DullahanAd
visibleOnly: false,
onScreenOnly: false,
interactiveOnly: false,
timeout: 200,
timeout: findElementTimeout,
promise: true,
expectNoMatches: false
};
Expand Down

0 comments on commit 10dfb3e

Please sign in to comment.