Reset the environment. :param options: options for the environment. The options are: - storage_state: the path to the storage state file
(
self,
*,
seed: int | None = None,
options: dict[str, str] | None = None,
)
| 71 | await self.page.goto(start_url) |
| 72 | |
| 73 | async def areset( |
| 74 | self, |
| 75 | *, |
| 76 | seed: int | None = None, |
| 77 | options: dict[str, str] | None = None, |
| 78 | ) -> tuple[npt.NDArray[np.uint8], dict[str, object]]: |
| 79 | """ |
| 80 | Reset the environment. |
| 81 | :param options: options for the environment. The options are: |
| 82 | - storage_state: the path to the storage state file |
| 83 | """ |
| 84 | super().reset(seed=seed, options=options) |
| 85 | if self.reset_finished: |
| 86 | await self.context_manager.__aexit__() |
| 87 | if options is not None and "config_file" in options: |
| 88 | config_file = Path(options["config_file"]) |
| 89 | if config_file.exists(): |
| 90 | await self.setup(config_file=config_file) |
| 91 | else: |
| 92 | raise ValueError(f"Config state {config_file} does not exist.") |
| 93 | else: |
| 94 | await self.setup() |
| 95 | self.reset_finished = True |
| 96 | content = await self.page.content() |
| 97 | screenshot = png_bytes_to_numpy(await self.page.screenshot()) |
| 98 | return ( |
| 99 | screenshot, |
| 100 | {"page": DetachedPage(self.page.url, content)}, |
| 101 | ) |
| 102 | |
| 103 | def reset( |
| 104 | self, |