Top level get. Utilizes the first tab to retrieve the given url. This is a convenience function known from selenium. This function handles waits/sleeps and detects when DOM events fired, so it's the safest way of navigating. :param url: the url to naviga
(
self,
url="about:blank",
new_tab: bool = False,
new_window: bool = False,
**kwargs,
)
| 322 | return items |
| 323 | |
| 324 | async def get( |
| 325 | self, |
| 326 | url="about:blank", |
| 327 | new_tab: bool = False, |
| 328 | new_window: bool = False, |
| 329 | **kwargs, |
| 330 | ): |
| 331 | """ |
| 332 | Top level get. Utilizes the first tab to retrieve the given url. |
| 333 | This is a convenience function known from selenium. |
| 334 | This function handles waits/sleeps and detects when DOM events fired, |
| 335 | so it's the safest way of navigating. |
| 336 | :param url: the url to navigate to |
| 337 | :param new_tab: open new tab |
| 338 | :param new_window: open new window |
| 339 | :return: Page |
| 340 | """ |
| 341 | if not self.browser: |
| 342 | raise AttributeError( |
| 343 | "This page/tab has no browser attribute, " |
| 344 | "so you can't use get()" |
| 345 | ) |
| 346 | if new_window and not new_tab: |
| 347 | new_tab = True |
| 348 | if new_tab: |
| 349 | if ( |
| 350 | getattr(sb_config, "incognito", None) |
| 351 | or ( |
| 352 | getattr(sb_config, "_cdp_browser", None) |
| 353 | in ["comet", "atlas"] |
| 354 | ) |
| 355 | ): |
| 356 | return await self.browser.get( |
| 357 | url, new_tab=False, new_window=True, **kwargs |
| 358 | ) |
| 359 | else: |
| 360 | return await self.browser.get( |
| 361 | url, new_tab=True, new_window=False, **kwargs |
| 362 | ) |
| 363 | else: |
| 364 | if not kwargs: |
| 365 | frame_id, loader_id, *_ = await self.send( |
| 366 | cdp.page.navigate(url) |
| 367 | ) |
| 368 | await self |
| 369 | return self |
| 370 | else: |
| 371 | return await self.browser.get( |
| 372 | url, new_tab=False, new_window=False, **kwargs |
| 373 | ) |
| 374 | |
| 375 | async def open(self, url="about:blank"): |
| 376 | return await self.get(url=url) |
no test coverage detected