Skip to content

Commit 50035bb

Browse files
fix: make lib compatible to WebdriverIO v8 (#43)
1 parent 9963f3e commit 50035bb

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ const SIMMERJS = fs
4646
let _config: Partial<Config>
4747

4848
async function injectDOMTestingLibrary(container: ElementBase) {
49-
const shouldInject = await container.execute(function () {
49+
const shouldInject = await container.parent.execute(function () {
5050
return {
5151
domTestingLibrary: !window.TestingLibraryDom,
5252
simmer: !window.Simmer,
5353
}
5454
})
5555

5656
if (shouldInject.domTestingLibrary) {
57-
await container.execute(function (library: string) {
57+
await container.parent.execute(function (library: string) {
5858
// add DOM Testing Library to page as a script tag to support Firefox
5959
if (navigator.userAgent.includes('Firefox')) {
6060
const script = document.createElement('script')
@@ -68,10 +68,10 @@ async function injectDOMTestingLibrary(container: ElementBase) {
6868
}
6969

7070
if (shouldInject.simmer) {
71-
await container.execute(SIMMERJS)
71+
await container.parent.execute(SIMMERJS)
7272
}
7373

74-
await container.execute(function (config: Config) {
74+
await container.parent.execute(function (config: Config) {
7575
window.TestingLibraryDom.configure(config)
7676
}, _config)
7777
}
@@ -199,7 +199,7 @@ function createQuery(container: ElementBase, queryName: QueryName) {
199199
await injectDOMTestingLibrary(container)
200200

201201
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
202-
const result: SerializedQueryResult = await container.executeAsync(
202+
const result: SerializedQueryResult = await container.parent.executeAsync(
203203
executeQuery,
204204
queryName,
205205
container,

src/wdio-types.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ export type ChainablePromiseElementBase<T> = Promise<T> & {$: $}
2626

2727
export type ElementBase = {
2828
$: $
29-
30-
execute<T>(
31-
script: string | ((...args: any[]) => T),
32-
...args: any[]
33-
): Promise<T>
34-
35-
execute<T>(script: string | ((...args: any[]) => T), ...args: any[]): T
36-
37-
executeAsync(script: string | ((...args: any[]) => void), ...args: any[]): any
29+
parent: {
30+
execute<T>(
31+
script: string | ((...args: any[]) => T),
32+
...args: any[]
33+
): Promise<T>
34+
35+
execute<T>(script: string | ((...args: any[]) => T), ...args: any[]): T
36+
37+
executeAsync(script: string | ((...args: any[]) => void), ...args: any[]): any
38+
}
3839
}
3940

4041
export type BrowserBase = {

0 commit comments

Comments
 (0)