Skip to content

Commit

Permalink
fix!: add support for wdio@9
Browse files Browse the repository at this point in the history
  • Loading branch information
Badisi committed Sep 6, 2024
1 parent bd18ba7 commit 73004fd
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions projects/library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
},
"peerDependencies": {
"@angular/cdk": ">= 13 < 18",
"@wdio/logger": ">= 8 < 9",
"webdriverio": ">= 8 < 9"
"@wdio/logger": ">= 9 < 10",
"webdriverio": ">= 9 < 10"
},
"dependencies": {
"@colors/colors": "^1.6.0"
Expand Down
2 changes: 1 addition & 1 deletion projects/library/src/WebdriverIOHarnessEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class WebdriverIOHarnessEnvironment extends HarnessEnvironment<WebdriverI
/** Gets a list of all elements matching the given selector under this environment's root element. */
protected async getAllRawElements(selector: string): Promise<WebdriverIO.Element[]> {
log.info(`${magenta('GET_ALL_RAW_ELEMENTS')} ${green(selector.toString())}`);
return [...(await this.rawRootElement.$$(selector))];
return [...(await this.rawRootElement.$$(selector).getElements())];
}

/** Gets the root element for the document. */
Expand Down
2 changes: 1 addition & 1 deletion projects/library/src/WebdriverIOTestElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class WebdriverIOTestElement implements TestElement {
async selectOptions(...optionIndexes: number[]): Promise<void> {
this.logAction('SELECT_OPTIONS', `[${optionIndexes.join(', ')}]`);

const options = await this.hostElement.$$('option');
const options = await this.hostElement.$$('option').getElements();
const indexes = new Set(optionIndexes); // Convert to a set to remove duplicates.

if (options.length && indexes.size) {
Expand Down
2 changes: 1 addition & 1 deletion projects/library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const getHarness = async <T extends ComponentHarness>(
export const createHarnessEnvironment = async (
rootElement?: WebdriverIO.Element
): Promise<WebdriverIOHarnessEnvironment> => {
return WebdriverIOHarnessEnvironment.loader(rootElement || await $('body'));
return WebdriverIOHarnessEnvironment.loader(rootElement ?? await $('//body').getElement());
};

/**
Expand Down
3 changes: 2 additions & 1 deletion projects/library/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"strictPropertyInitialization": true,
"noUnusedLocals": true,
"types": [
"node"
"node",
"@wdio/globals/types"
]
},
"compileOnSave": false,
Expand Down
2 changes: 1 addition & 1 deletion projects/tests-e2e/harness.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Angular Material Harness', () => {
* @error ERROR webdriver: Request failed with status 404 due to invalid session id: invalid session id
* Moreover this api is not efficient as it loops through all the cells no matter the filter.
*/
const cellElement = await calendar.element().$('span.mat-calendar-body-cell-content=20');
const cellElement = await calendar.element().$('span.mat-calendar-body-cell-content=20').getElement();
const cell = await getHarness(MatCalendarCellHarness, cellElement);
await cell.select();
/** -- */
Expand Down
6 changes: 4 additions & 2 deletions projects/tests-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"moduleResolution": "node",
"moduleResolution": "node",
"module": "ESNext",
"target": "es2022",
"lib": [
Expand All @@ -9,8 +9,10 @@
],
"types": [
"node",
"jasmine",
"@wdio/globals/types",
"expect-webdriverio/jasmine",
"@wdio/jasmine-framework"
"@wdio/jasmine-framework",
]
}
}
10 changes: 4 additions & 6 deletions projects/tests-e2e/wdio.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,25 @@ export const config: Options.Testrunner = {
// ====================
runner: 'local',
injectGlobals: false,
autoCompileOpts: {
tsNodeOpts: {
project: 'tsconfig.json'
}
},
//
// ==================
// Specify Test Files
// ==================
specs: [
'./**/*.e2e.ts'
],
filesToWatch: [
'./src/**/*.ts'
],
//
// ============
// Capabilities
// ============
maxInstances: debug ? 1 : 100,
capabilities: [{
maxInstances: 5,
browserName: 'chrome',
browserVersion: 'stable',
maxInstances: 5,
acceptInsecureCerts: true,
'goog:chromeOptions': {
args: headless ? ['--headless', '--disable-gpu', '--disable-dev-shm-usage'] : [debug ? '--auto-open-devtools-for-tabs' : '']
Expand Down

0 comments on commit 73004fd

Please sign in to comment.