MCPcopy
hub / github.com/reflex-dev/reflex / frontend

Method frontend

reflex/testing.py:596–676  ·  view source on GitHub ↗

Get a selenium webdriver instance pointed at the app. Args: driver_clz: webdriver.Chrome (default), webdriver.Firefox, webdriver.Safari, webdriver.Edge, etc driver_kwargs: additional keyword arguments to pass to the webdriver constructor d

(
        self,
        driver_clz: type[WebDriver] | None = None,
        driver_kwargs: dict[str, Any] | None = None,
        driver_options: ArgOptions | None = None,
        driver_option_args: list[str] | None = None,
        driver_option_capabilities: dict[str, Any] | None = None,
    )

Source from the content-addressed store, hash-verified

594 return backend.servers[0].sockets[0]
595
596 def frontend(
597 self,
598 driver_clz: type[WebDriver] | None = None,
599 driver_kwargs: dict[str, Any] | None = None,
600 driver_options: ArgOptions | None = None,
601 driver_option_args: list[str] | None = None,
602 driver_option_capabilities: dict[str, Any] | None = None,
603 ) -> WebDriver:
604 """Get a selenium webdriver instance pointed at the app.
605
606 Args:
607 driver_clz: webdriver.Chrome (default), webdriver.Firefox, webdriver.Safari,
608 webdriver.Edge, etc
609 driver_kwargs: additional keyword arguments to pass to the webdriver constructor
610 driver_options: selenium ArgOptions instance to pass to the webdriver constructor
611 driver_option_args: additional arguments for the webdriver options
612 driver_option_capabilities: additional capabilities for the webdriver options
613
614 Returns:
615 Instance of the given webdriver navigated to the frontend url of the app.
616
617 Raises:
618 RuntimeError: when selenium is not importable or frontend is not running
619 """
620 if not has_selenium:
621 msg = (
622 "Frontend functionality requires `selenium` to be installed, "
623 "and it could not be imported."
624 )
625 raise RuntimeError(msg)
626 if self.frontend_url is None:
627 msg = "Frontend is not running."
628 raise RuntimeError(msg)
629 want_headless = False
630 if environment.APP_HARNESS_HEADLESS.get():
631 want_headless = True
632 if driver_clz is None:
633 requested_driver = environment.APP_HARNESS_DRIVER.get()
634 driver_clz = getattr(webdriver, requested_driver) # pyright: ignore [reportPossiblyUnboundVariable]
635 if driver_options is None:
636 driver_options = getattr(webdriver, f"{requested_driver}Options")() # pyright: ignore [reportPossiblyUnboundVariable]
637 if driver_clz is webdriver.Chrome: # pyright: ignore [reportPossiblyUnboundVariable]
638 if driver_options is None:
639 from selenium.webdriver.chrome.options import Options
640
641 driver_options = Options() # pyright: ignore [reportPossiblyUnboundVariable]
642 driver_options.add_argument("--class=AppHarness")
643 if want_headless:
644 driver_options.add_argument("--headless=new")
645 elif driver_clz is webdriver.Firefox: # pyright: ignore [reportPossiblyUnboundVariable]
646 if driver_options is None:
647 from selenium.webdriver.firefox.options import Options
648
649 driver_options = Options() # pyright: ignore [reportPossiblyUnboundVariable]
650 if want_headless:
651 driver_options.add_argument("-headless")
652 elif driver_clz is webdriver.Edge: # pyright: ignore [reportPossiblyUnboundVariable]
653 if driver_options is None:

Callers 15

driverFunction · 0.80
driverFunction · 0.80
driverFunction · 0.80
driverFunction · 0.80
driverFunction · 0.80
driverFunction · 0.80
driverFunction · 0.80
test_connection_bannerFunction · 0.80
test_cloud_bannerFunction · 0.80
test_tailwind_appFunction · 0.80
driverFunction · 0.80
driverFunction · 0.80

Calls 3

splitMethod · 0.80
itemsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected