Download task_007/tests/edit_question.js from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 729 Bytes
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_007/tests/edit_question.js
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_007/tests/edit_question.js
-
curl -L -o edit_question.js https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_007/tests/edit_question.js
729 Bytes
| // Accept inline, accessible HTML-dialog and native prompt editing flows. | |
| async function editQuestion(page, button, text) { | |
| const promptHandler = dialog => dialog.type() === 'prompt' ? dialog.accept(text) : dialog.dismiss(); | |
| page.on('dialog', promptHandler); | |
| try { | |
| await button.click(); | |
| const dialog = page.getByRole('dialog'); | |
| if (await dialog.count() && await dialog.first().isVisible()) { | |
| const field = dialog.first().locator('input,textarea').first(); | |
| if (await field.count()) await field.fill(text); | |
| await dialog.first().getByRole('button', {name: /save|保存|确认|确定/i}).first().click(); | |
| } | |
| } finally { page.off('dialog', promptHandler); } | |
| } | |
| module.exports = {editQuestion}; | |