-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c551143
commit 9c53411
Showing
6 changed files
with
269 additions
and
265 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { BrowserContext, Page } from "playwright"; | ||
import { Action, ActionOptions } from "../types"; | ||
import { delay, validateOptions } from "../utils/utils"; | ||
|
||
type RemoveOptions = { | ||
[P in keyof ActionOptions as Exclude<P, "cookies" | "value">]-?: ActionOptions[P]; | ||
}; | ||
export class Remove implements Action { | ||
options: RemoveOptions; | ||
|
||
constructor(options: RemoveOptions) { | ||
validateOptions(options, { | ||
element: "Remove action requires an element to remove", | ||
}); | ||
this.options = options; | ||
} | ||
|
||
async execute(page: Page, _context?: BrowserContext): Promise<void> { | ||
await page.$$eval(this.options.element, (elements) => { | ||
elements.forEach((element) => { | ||
element.remove(); | ||
}); | ||
}); | ||
await delay(100); | ||
} | ||
} |
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
Oops, something went wrong.