Skip to content

Commit 602be6b

Browse files
committed
Try dynamically selecting options for file_path_field
1 parent 208ec17 commit 602be6b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/test_app/tests/test_components.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,9 @@ def test_basic_form(self):
645645
self.page.locator("#id_decimal_field").type("0.123", delay=CLICK_DELAY)
646646
self.page.locator("#id_duration_field").type("1", delay=CLICK_DELAY)
647647
self.page.locator("#id_email_field").type("[email protected]", delay=CLICK_DELAY)
648-
self.page.locator("#id_file_path_field").select_option("manage.py")
648+
file_path_field_options = self.page.query_selector_all("#id_file_path_field option")
649+
file_path_field_values: list[str] = [option.get_attribute("value") for option in file_path_field_options]
650+
self.page.locator("#id_file_path_field").select_option(file_path_field_values[1])
649651
self.page.locator("#id_float_field").type("1.2345", delay=CLICK_DELAY)
650652
self.page.locator("#id_generic_ip_address_field").type("127.0.0.1", delay=CLICK_DELAY)
651653
self.page.locator("#id_integer_field").type("123", delay=CLICK_DELAY)
@@ -662,7 +664,6 @@ def test_basic_form(self):
662664
self.page.locator("#id_uuid_field").type("550e8400-e29b-41d4-a716-446655440000", delay=CLICK_DELAY)
663665
self.page.locator("#id_combo_field").type("[email protected]", delay=CLICK_DELAY)
664666
self.page.locator("#id_password_field").type("password", delay=CLICK_DELAY)
665-
666667
model_choice_field_options = self.page.query_selector_all("#id_model_multiple_choice_field option")
667668
model_choice_field_values: list[str] = [option.get_attribute("value") for option in model_choice_field_options]
668669
self.page.locator("#id_model_choice_field").select_option(model_choice_field_values[0])
@@ -741,7 +742,9 @@ def test_bootstrap_form(self):
741742
self.page.locator("#id_decimal_field").type("0.123", delay=CLICK_DELAY)
742743
self.page.locator("#id_duration_field").type("1", delay=CLICK_DELAY)
743744
self.page.locator("#id_email_field").type("[email protected]", delay=CLICK_DELAY)
744-
self.page.locator("#id_file_path_field").select_option("manage.py")
745+
file_path_field_options = self.page.query_selector_all("#id_file_path_field option")
746+
file_path_field_values: list[str] = [option.get_attribute("value") for option in file_path_field_options]
747+
self.page.locator("#id_file_path_field").select_option(file_path_field_values[1])
745748
self.page.locator("#id_float_field").type("1.2345", delay=CLICK_DELAY)
746749
self.page.locator("#id_generic_ip_address_field").type("127.0.0.1", delay=CLICK_DELAY)
747750
self.page.locator("#id_integer_field").type("123", delay=CLICK_DELAY)

0 commit comments

Comments
 (0)