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
2 changes: 1 addition & 1 deletion lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ class Playwright extends Helper {
let optionToSelect = '';

try {
optionToSelect = await el.locator('option', { hasText: option }).textContent();
optionToSelect = (await el.locator('option', { hasText: option }).textContent()).trim();
} catch (e) {
optionToSelect = option;
}
Expand Down
25 changes: 25 additions & 0 deletions test/data/app/view/form/select_additional_spaces.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html>
<body>
<form action="/form/complex" method="POST">
<label for="age">Select your age</label>
<select name="age" id="age">
<option value="child">
below 13
</option>
<option value="teenage">
13-21
</option>
<option value="adult">
21-60
</option>
<option value="oldfag" selected="selected">
60-100
</option>
<option value="dead">
100-210
</option>
</select>
<input type="submit" value="Submit" />
</form>
</body>
</html>
7 changes: 7 additions & 0 deletions test/helper/webapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,13 @@ module.exports.tests = function () {
await I.click('Submit');
assert.deepEqual(formContents('like'), ['play', 'adult']);
});

it('should select option by label and option text with additional spaces', async () => {
await I.amOnPage('/form/select_additional_spaces');
await I.selectOption('Select your age', '21-60');
await I.click('Submit');
assert.equal(formContents('age'), 'adult');
});
});

describe('#executeScript', () => {
Expand Down