Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions atest/test/02_Content_Keywords/select_lists.robot
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Get Select Options

Get Select Options Strict
Run Keyword And Expect Error
... *strict mode violation*//select*resolved to 4 elements*
... *strict mode violation*//select*resolved to 5 elements*
... Get Select Options //select
Set Strict Mode False
${options} = Get Select Options //select
Expand Down Expand Up @@ -100,6 +100,9 @@ Select Options By With Nonmatching Selector
Select Options By Text When Select Does Not Have Value Attribute
Select Options By id=noValue text Option 2

Select Options By Text When Select Value And Text Are Different
Select Options By id=ValueAndTextDifferent text 0

Deselect Options Implicitly
Select Option And Verify Selection text select[name=possible_channels]

Expand All @@ -109,7 +112,7 @@ Deselect Options Explicitly

Deselect Options With Strict
Run Keyword And Expect Error
... *strict mode violation*//select*resolved to 4 elements*
... *strict mode violation*//select*resolved to 5 elements*
... Deselect Options //select
Set Strict Mode False
Deselect Options //select
Expand Down
14 changes: 14 additions & 0 deletions node/dynamic-test-app/static/prefilled_email_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
<option value="others">Others</option>
</select>
</td>
</tr>
<tr>
<td>Select without value:</td>
<td>
<select id="noValue">
Expand All @@ -81,6 +83,18 @@
</select>
</td>
</tr>
<tr>
<td>Select when value and text are not same</td>
<td>
<select id="ValueAndTextDifferent">
<option value="null">0</option>
<option value="1">0</option>
<option value="2">1</option>
<option value="3">2</option>
<option value="4">3</option>
</select>
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="submit"/></td>
</tr>
Expand Down
13 changes: 9 additions & 4 deletions node/playwright-wrapper/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ export async function selectOption(
const attributeName = Object.keys(matcher[0])[0];
const selectedOptions = [];
for (const selectedOption of result) {
const locatorOptions = locator.locator(
`xpath=./option[@value="${selectedOption}" or text()="${selectedOption}"]`,
);
const element = await locatorOptions.elementHandle();
let element = undefined;
const locatorOptionsValue = locator.locator(`option[value="${selectedOption}"]`);
try {
element = await locatorOptionsValue.elementHandle();
} catch {
logger.info(`Could not find option element with ${selectedOption} value, try with text.`);
const locatorOptionsText = locator.locator(`xpath=./option[text()="${selectedOption}"]`);
element = await locatorOptionsText.elementHandle();
}
exists(element, `The ${selectedOption} option element did not exist.`);
selectedOptions.push(String(await element.getProperty(attributeName)));
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@medv/finder": "^2.1.0",
"google-protobuf": "3.19.3",
"pino": "^7.8.0",
"playwright": "^1.18.1",
"playwright": "^1.19.1",
"uuid": "^8.3.2"
},
"scripts": {
Expand Down