File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -1805,7 +1805,7 @@ class Playwright extends Helper {
1805
1805
let optionToSelect = '' ;
1806
1806
1807
1807
try {
1808
- optionToSelect = await el . locator ( 'option' , { hasText : option } ) . textContent ( ) ;
1808
+ optionToSelect = ( await el . locator ( 'option' , { hasText : option } ) . textContent ( ) ) . trim ( ) ;
1809
1809
} catch ( e ) {
1810
1810
optionToSelect = option ;
1811
1811
}
Original file line number Diff line number Diff line change
1
+ <html >
2
+ <body >
3
+ <form action =" /form/complex" method =" POST" >
4
+ <label for = " age" >Select your age</label >
5
+ <select name = " age" id = " age" >
6
+ <option value = " child" >
7
+ below 13
8
+ </option >
9
+ <option value = " teenage" >
10
+ 13-21
11
+ </option >
12
+ <option value = " adult" >
13
+ 21-60
14
+ </option >
15
+ <option value = " oldfag" selected = " selected" >
16
+ 60-100
17
+ </option >
18
+ <option value = " dead" >
19
+ 100-210
20
+ </option >
21
+ </select >
22
+ <input type = " submit" value = " Submit" />
23
+ </form >
24
+ </body >
25
+ </html >
Original file line number Diff line number Diff line change @@ -433,6 +433,13 @@ module.exports.tests = function () {
433
433
await I . click ( 'Submit' ) ;
434
434
assert . deepEqual ( formContents ( 'like' ) , [ 'play' , 'adult' ] ) ;
435
435
} ) ;
436
+
437
+ it ( 'should select option by label and option text with additional spaces' , async ( ) => {
438
+ await I . amOnPage ( '/form/select_additional_spaces' ) ;
439
+ await I . selectOption ( 'Select your age' , '21-60' ) ;
440
+ await I . click ( 'Submit' ) ;
441
+ assert . equal ( formContents ( 'age' ) , 'adult' ) ;
442
+ } ) ;
436
443
} ) ;
437
444
438
445
describe ( '#executeScript' , ( ) => {
You can’t perform that action at this time.
0 commit comments