-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename WDIO adapter filename to match class name
- Loading branch information
Showing
3 changed files
with
39 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,3 @@ | ||
import { Browser } from 'mugshot'; | ||
import WebdriverIOAdapter from './lib/webdriverio-adapter'; | ||
|
||
/* istanbul ignore next because this will get stringified and sent to the browser */ | ||
function getBoundingRect(selector: string): DOMRect { | ||
// @ts-ignore because querySelector can be null and we don't | ||
// care about browsers that don't support it. | ||
return document.querySelector(selector).getBoundingClientRect(); | ||
} | ||
|
||
/** | ||
* API adapter for WebdriverIO to make working with it saner. | ||
*/ | ||
export default class WebdriverIOAdapter implements Browser { | ||
private browser: WebDriver.ClientAsync & WebdriverIOAsync.Browser; | ||
|
||
constructor(browser: WebDriver.ClientAsync & WebdriverIOAsync.Browser) { | ||
this.browser = browser; | ||
} | ||
|
||
takeScreenshot = async () => this.browser.takeScreenshot(); | ||
|
||
getElementRect = async (selector: string) => { | ||
// @ts-ignore because the return type is not properly inferred | ||
const rect: DOMRect = await this.browser.execute( | ||
getBoundingRect, | ||
selector | ||
); | ||
|
||
return { | ||
x: rect.x, | ||
y: rect.y, | ||
width: rect.width, | ||
height: rect.height | ||
}; | ||
}; | ||
} | ||
export default WebdriverIOAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Browser } from 'mugshot'; | ||
|
||
/* istanbul ignore next because this will get stringified and sent to the browser */ | ||
function getBoundingRect(selector: string): DOMRect { | ||
// @ts-ignore because querySelector can be null and we don't | ||
// care about browsers that don't support it. | ||
return document.querySelector(selector).getBoundingClientRect(); | ||
} | ||
|
||
/** | ||
* API adapter for WebdriverIO to make working with it saner. | ||
*/ | ||
export default class WebdriverIOAdapter implements Browser { | ||
private browser: WebDriver.ClientAsync & WebdriverIOAsync.Browser; | ||
|
||
constructor(browser: WebDriver.ClientAsync & WebdriverIOAsync.Browser) { | ||
this.browser = browser; | ||
} | ||
|
||
takeScreenshot = async () => this.browser.takeScreenshot(); | ||
|
||
getElementRect = async (selector: string) => { | ||
// @ts-ignore because the return type is not properly inferred | ||
const rect: DOMRect = await this.browser.execute( | ||
getBoundingRect, | ||
selector | ||
); | ||
|
||
return { | ||
x: rect.x, | ||
y: rect.y, | ||
width: rect.width, | ||
height: rect.height | ||
}; | ||
}; | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/webdriverio/tests/gui/specs/webdriverio-adapter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters