(action: str)
| 43 | |
| 44 | |
| 45 | def parse_action(action: str) -> PlaywrightScript: |
| 46 | splitted = action.strip().split(" ") |
| 47 | assert len(splitted) >= 2 |
| 48 | match splitted[:2]: |
| 49 | case ["goto", url]: |
| 50 | assert len(splitted) == 2 |
| 51 | return PlaywrightScript("goto", url) |
| 52 | case ["get_by_role", destination]: |
| 53 | assert len(splitted) >= 4 |
| 54 | match splitted[2:]: |
| 55 | case [name, operation]: |
| 56 | return PlaywrightScript( |
| 57 | "get_by_role", destination, name, operation |
| 58 | ) |
| 59 | case [name, operation, value]: |
| 60 | return PlaywrightScript( |
| 61 | "get_by_role", destination, name, operation, value |
| 62 | ) |
| 63 | case _: |
| 64 | raise ValueError("Invalid action") |
| 65 | case _: |
| 66 | raise ValueError(f"Invalid action {action}") |
| 67 | |
| 68 | |
| 69 | class ScriptBrowserEnv(Env[dict[str, Observation], Action]): |
nothing calls this directly
no test coverage detected