class Duplicate(WebDriver):
    def __init__(self, sess_id, svr_addr):
        super(WebDriver, self).__init__()
        self.command_executor = RemoteConnection(svr_addr, True)
        self.session_id = sess_id
        self.error_handler = ErrorHandler()
        self.file_detector = LocalFileDetector()

    #override
    def execute(self, driver_command, params=None):
        if self.session_id is not None:
            if not params:
                params = {'sessionId': self.session_id}
            elif 'sessionId' not in params:
                params['sessionId'] = self.session_id

        params = self._wrap_value(params)
        response = self.command_executor.execute(driver_command, params)
        if response:
            self.error_handler.check_response(response)
            response['value'] = self._unwrap_value(response.get('value', None))
            return response
        # If the server doesn't send a response, assume the command was
        # a success
        return {'success': 0, 'value': None, 'sessionId': self.session_id}
예제 #2
0
    def __init__(self, session_id=None, browser_name=''):
        command_executor = 'http://localhost:4444/wd/hub'
        platform = version = ''
        javascript_enabled = True

        self.command_executor = command_executor
        if type(self.command_executor) is str:
            self.command_executor = RemoteConnection(command_executor)

        self.command_executor._commands['GET_SESSION'] = (
            'GET', '/session/$sessionId')

        self.session_id = session_id
        self.capabilities = {}
        self.error_handler = ErrorHandler()

        if session_id:
            self.connect_to_session(browser_name=browser_name,
                                    platform=platform,
                                    version=version,
                                    javascript_enabled=javascript_enabled)
        else:
            self.start_session(browser_name=browser_name,
                               platform=platform,
                               version=version,
                               javascript_enabled=javascript_enabled)
예제 #3
0
    def __init__(self,
                 options=None,
                 capabilities=None,
                 service_url=None,
                 session_id=None):
        if options == None:
            self.service = False
        else:
            self.service = True
            self.address = options[0]
            self.who = options[1]
        # super(Chrome_Remote, self).__init__(port=port)
        if service_url is None and session_id is None:
            raise NameError

        if capabilities is None:
            capabilities = DesiredCapabilities.CHROME.copy()

        self.capabilities = dict(capabilities)

        self.w3c = True

        executor = ChromeRemoteConnection(remote_server_addr=service_url)
        self.session_id = session_id
        self.command_executor = executor
        self.command_executor.w3c = self.w3c
        if type(self.command_executor) is bytes or isinstance(
                self.command_executor, str):
            self.command_executor = RemoteConnection(self.command_executor,
                                                     keep_alive=True)
        self._is_remote = True
        self.error_handler = ErrorHandler()
        self._switch_to = SwitchTo(self)
        self._mobile = Mobile(self)
        self.file_detector = LocalFileDetector()
예제 #4
0
파일: dali_core.py 프로젝트: gridl/dali
 def __init__(self, remoteUrl, capabilities):
     ### @todo refactor me
     self.command_executor = RemoteConnection(remoteUrl)
     self.error_handler = ErrorHandler()
     self._is_remote = True
     self.start_client()
     self.session_id = capabilities["webdriver.remote.sessionid"]
     self.capabilities = capabilities
예제 #5
0
    def __init__(self, capabilities=None, service_url=None, session_id=None):
        if service_url is None and session_id is None:
            raise NameError

        if capabilities is None:
            capabilities = DesiredCapabilities.FIREFOX.copy()

        self.capabilities = dict(capabilities)
        self.w3c = True
        executor = ChromeRemoteConnection(remote_server_addr=service_url)
        self.session_id = session_id
        self.command_executor = executor
        self.command_executor.w3c = self.w3c
        if type(self.command_executor) is bytes or isinstance(self.command_executor, str):
            self.command_executor = RemoteConnection(self.command_executor, keep_alive=True)
        self._is_remote = True
        self.error_handler = ErrorHandler()
        self._switch_to = SwitchTo(self)
        self._mobile = Mobile(self)
        self.file_detector = LocalFileDetector()
예제 #6
0
 def __init__(self, *args, **kwargs):
     kwargs['command_executor'] = ChromeDriverProxyRemoteConnection(
         kwargs['command_executor'], keep_alive=kwargs['keep_alive'])
     super(self.__class__, self).__init__(*args, **kwargs)
     self.error_handler = ErrorHandler()
 def __init__(self, sess_id, svr_addr):
     super(WebDriver, self).__init__()
     self.command_executor = RemoteConnection(svr_addr, True)
     self.session_id = sess_id
     self.error_handler = ErrorHandler()
     self.file_detector = LocalFileDetector()
예제 #8
0
    def __init__(self,
                 command_executor='http://127.0.0.1:4444/wd/hub',
                 desired_capabilities=None,
                 browser_profile=None,
                 proxy=None,
                 keep_alive=False,
                 file_detector=None,
                 session_id=None,
                 w3c=True):
        """
        Create a new driver that will issue commands using the wire protocol.

        :Args:
         - 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.
        """
        if desired_capabilities is None:
            raise WebDriverException("Desired Capabilities can't be None")
        if not isinstance(desired_capabilities, dict):
            raise WebDriverException(
                "Desired Capabilities must be a dictionary")
        if proxy is not None:
            warnings.warn("Please use FirefoxOptions to set proxy",
                          DeprecationWarning)
            proxy.add_to_capabilities(desired_capabilities)
        if (desired_capabilities["browserName"] == 'firefox'):
            command_executor = FirefoxRemoteConnection(
                remote_server_addr=command_executor)
        self.command_executor = command_executor
        if type(self.command_executor) is bytes or isinstance(
                self.command_executor, str):
            self.command_executor = RemoteConnection(command_executor,
                                                     keep_alive=keep_alive)

        self._is_remote = True
        self.session_id = session_id  # added
        self.capabilities = dict(desired_capabilities)
        self.error_handler = ErrorHandler()
        self.start_client()
        if browser_profile is not None:
            warnings.warn("Please use FirefoxOptions to set browser profile",
                          DeprecationWarning)

        if session_id:
            if desired_capabilities["browserName"] != "firefox":
                self.connect_to_session(desired_capabilities)  # added
            else:
                pass
            self.w3c = w3c  # modified by zhengchun
        else:
            self.start_session(desired_capabilities, browser_profile)

        self._switch_to = SwitchTo(self)
        self._mobile = Mobile(self)
        self.file_detector = file_detector or LocalFileDetector()
예제 #9
0
def handler():
    yield ErrorHandler()