-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add hover/unhover, expose option types for playwright
- Loading branch information
1 parent
f1e8574
commit b45d3a2
Showing
6 changed files
with
85 additions
and
11 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
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
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
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
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
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,23 @@ | ||
import type { UserEvent } from '../../../context' | ||
import { PlaywrightBrowserProvider } from '../providers/playwright' | ||
import { WebdriverBrowserProvider } from '../providers/webdriver' | ||
import type { UserEventCommand } from './utils' | ||
|
||
export const hover: UserEventCommand<UserEvent['hover']> = async ( | ||
context, | ||
xpath, | ||
options = {}, | ||
) => { | ||
if (context.provider instanceof PlaywrightBrowserProvider) { | ||
await context.frame.locator(`xpath=${xpath}`).hover(options) | ||
} | ||
else if (context.provider instanceof WebdriverBrowserProvider) { | ||
const browser = context.browser | ||
const markedXpath = `//${xpath}` | ||
const element = await browser.$(markedXpath) | ||
await element.moveTo(options) | ||
} | ||
else { | ||
throw new TypeError(`Provider "${context.provider.name}" does not support hover`) | ||
} | ||
} |