@@ -45,6 +45,22 @@ async def test_select_option_should_select_single_option_by_label(
4545 assert await page .evaluate ("result.onChange" ) == ["indigo" ]
4646
4747
48+ async def test_select_option_should_select_single_option_by_empty_label (
49+ page : Page , server : Server
50+ ) -> None :
51+ await page .set_content (
52+ """
53+ <select>
54+ <option value="indigo">Indigo</option>
55+ <option value="violet"></option>
56+ </select>
57+ """
58+ )
59+ assert await page .locator ("select" ).input_value () == "indigo"
60+ await page .select_option ("select" , label = "" )
61+ assert await page .locator ("select" ).input_value () == "violet"
62+
63+
4864async def test_select_option_should_select_single_option_by_handle (
4965 page : Page , server : Server
5066) -> None :
@@ -65,6 +81,14 @@ async def test_select_option_should_select_single_option_by_index(
6581 assert await page .evaluate ("result.onChange" ) == ["brown" ]
6682
6783
84+ async def test_select_option_should_select_single_option_by_index_0 (
85+ page : Page , server : Server
86+ ) -> None :
87+ await page .goto (server .PREFIX + "/input/select.html" )
88+ await page .select_option ("select" , index = 0 )
89+ assert await page .evaluate ("result.onInput" ) == ["black" ]
90+
91+
6892async def test_select_option_should_select_only_first_option (
6993 page : Page , server : Server
7094) -> None :
@@ -112,6 +136,23 @@ async def test_select_option_should_select_multiple_options_with_attributes(
112136 assert await page .evaluate ("result.onChange" ) == ["blue" , "gray" , "green" ]
113137
114138
139+ async def test_select_option_should_select_option_with_empty_value (
140+ page : Page , server : Server
141+ ) -> None :
142+ await page .goto (server .EMPTY_PAGE )
143+ await page .set_content (
144+ """
145+ <select>
146+ <option value="first">First</option>
147+ <option value="">Second</option>
148+ </select>
149+ """
150+ )
151+ assert await page .locator ("select" ).input_value () == "first"
152+ await page .select_option ("select" , value = "" )
153+ assert await page .locator ("select" ).input_value () == ""
154+
155+
115156async def test_select_option_should_respect_event_bubbling (
116157 page : Page , server : Server
117158) -> None :
0 commit comments