Skip to content

Commit

Permalink
fix: setValue error when inputs have no "type", e.g. select
Browse files Browse the repository at this point in the history
  • Loading branch information
dnotes committed Dec 17, 2024
1 parent 9a3261b commit a448e56
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/playwright/src/PlaywrightWorld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class PlaywrightWorld extends QuickPickleWorld {
*/
async setValue(locator:Locator, value:string|any) {
let { tag, type, role } = await locator.evaluate((el) => ({ tag:el.tagName.toLowerCase(), type:el.getAttribute('type')?.toLowerCase(), role:el.getAttribute('role')?.toLowerCase() }), undefined, { timeout: this.worldConfig.stepTimeout })
if (!tag || !type) throw new Error(`Could not find element with locator: ${locator.toString()}`)
if (!tag) throw new Error(`Could not find element with locator: ${locator.toString()}`)
if (tag === 'select') {
let values = value.split(/\s*(?<!\\),\s*/).map((v:string) => v.replace(/\\,/g, ','))
await locator.selectOption(values, { timeout: this.worldConfig.stepTimeout })
Expand Down

0 comments on commit a448e56

Please sign in to comment.