How to use the arsenic.connection.RemoteConnection function in arsenic

To help you get started, we’ve selected a few arsenic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HDE / arsenic / tests / test_real_browsers.py View on Github external
async def test_change_window(session):
    if isinstance(session, CompatSession) or isinstance(
        session.driver.connection, RemoteConnection
    ):
        raise pytest.skip("not supported in compat session at the moment")
    handles = await session.get_window_handles()
    assert len(handles) == 1
    for i in range(4):
        await session.execute_script("window.open();")

    async def checker():
        handles = await session.get_window_handles()
        if len(handles) == 5:
            return handles
        return False

    handles = await session.wait(5, checker)
    await session.switch_to_window(handles[2])
    current = await session.get_window_handle()
github HDE / arsenic / tests / test_real_browsers.py View on Github external
async def test_chained_actions(session):
    if isinstance(session.browser, Firefox) and isinstance(
        session.driver.connection, RemoteConnection
    ):
        raise pytest.skip("remote firefox actions do not work")

    async def check(actions, expected):
        await session.perform_actions(actions)
        output = await session.get_element("#output")
        assert expected == await output.get_text()

    await session.get("/actions/")
    output = await session.wait_for_element(5, "#output")
    assert "" == await output.get_text()

    await session.get("/actions/")

    output = await session.wait_for_element(5, "#output")
    assert "" == await output.get_text()
github HDE / arsenic / src / arsenic / drivers / remote.py View on Github external
- command_executor - Either a string representing URL of the remote server or a custom
             remote_connection.RemoteConnection object. Defaults to 'http://127.0.0.1:4444/wd/hub'.
         - desired_capabilities - A dictionary of capabilities to request when
             starting the browser session. Required parameter.
         - browser_profile - A selenium.webdriver.firefox.firefox_profile.FirefoxProfile object.
             Only used if Firefox is requested. Optional.
         - proxy - A selenium.webdriver.common.proxy.Proxy object. The browser session will
             be started with given proxy settings, if possible. Optional.
         - keep_alive - Whether to configure remote_connection.RemoteConnection to use
             HTTP keep-alive. Defaults to False.
         - file_detector - Pass custom file detector object during instantiation. If None,
             then default LocalFileDetector() will be used.
        """
        self.command_executor = command_executor
        if type(self.command_executor) is bytes or isinstance(self.command_executor, str):
            self.command_executor = RemoteConnection(
                client,
                remote_server_addr=command_executor
            )
        self._is_remote = True
        self.session_id = None
        self.capabilities = {}
        self.error_handler = ErrorHandler()
        self._switch_to = SwitchTo(self)
        self._mobile = Mobile(self)
        self.file_detector = file_detector or LocalFileDetector()
        self._browser_profile = browser_profile
        self._desired_capabilities  = desired_capabilities
github HDE / arsenic / src / arsenic / drivers / firefox.py View on Github external
client,
            executable_path,
            port=port,
            log_file=log_file,
            env=env
        )
        self.service_args = service_args or []

    def command_line_args(self):
        return ["--port", "%d" % self.port]

    async def send_remote_shutdown_command(self):
        pass


class FirefoxRemoteConnection(RemoteConnection):
    def __init__(self, client, *, remote_server_addr):
        super().__init__(client, remote_server_addr=remote_server_addr)
        self._commands["GET_CONTEXT"] = ('GET', '/session/$sessionId/moz/context')
        self._commands["SET_CONTEXT"] = ("POST", "/session/$sessionId/moz/context")
        self._commands["ELEMENT_GET_ANONYMOUS_CHILDREN"] = \
            ("POST", "/session/$sessionId/moz/xbl/$id/anonymous_children")
        self._commands["ELEMENT_FIND_ANONYMOUS_ELEMENTS_BY_ATTRIBUTE"] = \
            ("POST", "/session/$sessionId/moz/xbl/$id/anonymous_by_attribute")


class FirefoxContext:
    def __init__(self, driver, context):
        self.driver = driver
        self.context = context

    async def __aenter__(self):
github HDE / arsenic / src / arsenic / services.py View on Github external
async def start(self):
        closers = []
        headers = {}
        if self.auth:
            headers.update(self.auth.get_headers())
        try:
            session = ClientSession(headers=headers)
            closers.append(session.close)
            return WebDriver(RemoteConnection(session, self.url), closers)
        except:
            for closer in reversed(closers):
                await closer()
            raise