|
23 | 23 | ORDER_DEVELOPMENT_LAPTOP_PC_TASK_CONFIG_PATH, |
24 | 24 | ORDER_LOANER_LAPTOP_TASK_CONFIG_PATH, |
25 | 25 | ) |
26 | | -from browsergym.workarena.api.requests import ( |
| 26 | +from .utils.form import fill_text |
| 27 | +from ..api.requests import ( |
27 | 28 | get_request_by_id, |
28 | 29 | db_delete_from_table, |
29 | 30 | ) |
30 | | -from browsergym.workarena.tasks.base import AbstractServiceNowTask |
| 31 | +from .base import AbstractServiceNowTask |
31 | 32 |
|
32 | 33 | ADDITIONAL_SOFTWARE = [ |
33 | 34 | "Slack", |
@@ -310,18 +311,10 @@ def cheat(self, page: Page, chat_messages: list[str]) -> None: |
310 | 311 | element_id = element_control.get_attribute("id") # this look superfluous |
311 | 312 | text_element = iframe.query_selector(f'[id="{element_id}"]') |
312 | 313 | text_element.click() |
313 | | - from .utils.form import fill_text |
314 | | - |
315 | 314 | fill_text(page=page, input_field=text_element, value=value, iframe=iframe) |
| 315 | + |
316 | 316 | elif control_type == "select-one": |
317 | | - select_options = iframe.query_selector(f'select[id="{element_id}"]', strict=True) |
318 | | - select_options.click() |
319 | | - options = select_options.query_selector_all("option") |
320 | | - for option in options: |
321 | | - if option.inner_text().startswith(value): |
322 | | - page.keyboard.press("Enter") |
323 | | - break |
324 | | - page.keyboard.press("ArrowDown") |
| 317 | + iframe.locator(f"id={element_id}").select_option(value) |
325 | 318 | else: |
326 | 319 | raise ValueError(f"Unknown control type {control_type}") |
327 | 320 |
|
@@ -475,10 +468,13 @@ def validate(self, page: Page, chat_messages: list[str]) -> tuple[int, bool, str |
475 | 468 |
|
476 | 469 |
|
477 | 470 | def option_match_heuristic(value, option): |
478 | | - value = str(value).lower() |
479 | | - option = str(option).lower() |
480 | | - option = option.replace("_", " ") |
481 | | - return value == option |
| 471 | + def _process(x): |
| 472 | + x = str(x).lower() |
| 473 | + x = x.replace("_", "") |
| 474 | + x = x.replace(" ", "") |
| 475 | + return x |
| 476 | + |
| 477 | + return _process(value) == _process(option) |
482 | 478 |
|
483 | 479 |
|
484 | 480 | class OrderDeveloperLaptopTask(OrderHardwareTask): |
|
0 commit comments