def _update_command_executor(self, keep_alive): """Update command executor following directConnect feature""" direct_protocol = 'directConnectProtocol' direct_host = 'directConnectHost' direct_port = 'directConnectPort' direct_path = 'directConnectPath' if (not {direct_protocol, direct_host, direct_port, direct_path}.issubset(set(self.capabilities))): message = 'Direct connect capabilities from server were:\n' for key in [direct_protocol, direct_host, direct_port, direct_path]: message += '{}: \'{}\'\n'.format(key, self.capabilities.get(key, '')) logger.warning(message) return protocol = self.capabilities[direct_protocol] hostname = self.capabilities[direct_host] port = self.capabilities[direct_port] path = self.capabilities[direct_path] executor = '{scheme}://{hostname}:{port}{path}'.format( scheme=protocol, hostname=hostname, port=port, path=path ) logger.info('Updated request endpoint to %s', executor) # Override command executor self.command_executor = RemoteConnection(executor, keep_alive=keep_alive) self._addCommands()
def _update_command_executor(self, keep_alive): """Update command executor following directConnect feature""" direct_protocol = 'directConnectProtocol' direct_host = 'directConnectHost' direct_port = 'directConnectPort' direct_path = 'directConnectPath' if (not {direct_protocol, direct_host, direct_port, direct_path}.issubset(set(self.capabilities))): message = 'Direct connect capabilities from server were:\n' for key in [direct_protocol, direct_host, direct_port, direct_path]: message += '{}: \'{}\'\n'.format(key, self.capabilities.get(key, '')) logger.warning(message) return protocol = self.capabilities[direct_protocol] hostname = self.capabilities[direct_host] port = self.capabilities[direct_port] path = self.capabilities[direct_path] executor = '{scheme}://{hostname}:{port}{path}'.format( scheme=protocol, hostname=hostname, port=port, path=path ) logger.info('Updated request endpoint to %s', executor) # Override command executor self.command_executor = RemoteConnection(executor, keep_alive=keep_alive) self._addCommands()
def __install_application(): logger.info("Reading config file") with open(get_from_main_config( "clientConfigFilePath")) as json_client_file: data = json.load(json_client_file) logger.info("Installing app") return webdriver.Remote(get_from_main_config("connectionUrl"), data)
def get_buttons_by_id(id_name) -> list: logger.info("searching buttons with %s id" % id_name) result = __get_elements_by_id(id_name) result = [Button(i, "Element in list") for i in result] return result
def get_label_by_xpath(locator, name) -> Label: logger.info("searching label with %s xpath and name %s" % (locator, name)) return Label(ClientManager().driver.find_element(By.XPATH, locator), name)
def get_label_by_id(id_name, name) -> Label: logger.info("searching label with %s id and name %s" % (id_name, name)) return Label( ClientManager().driver.find_element_by_id( __get_id_with_add_id(id_name)), name)
def get_text_field_by_id(id_name, name) -> TextField: logger.info("searching element with %s id and name %s" % (id_name, name)) return TextField( ClientManager().driver.find_element_by_id( __get_id_with_add_id(id_name)), name)
def __get_elements_by_id(id_name) -> list: logger.info("searching elements with %s id" % id_name) return ClientManager().driver.find_elements_by_id( __get_id_with_add_id(id_name))
def get_button_by_id_without_app_id(id_name, name) -> Button: logger.info("searching element with %s id and name %s" % (id_name, name)) return Button(ClientManager().driver.find_element_by_id(id_name), name)
def configure_client(): logger.info("Setting implicitlyWait") ClientManager().driver.implicitly_wait( get_from_main_config("implicitlyWait"))
def clean_client(): logger.info("removing application") ClientManager().driver.remove_app(get_from_main_config("appId"))
def get_from_main_config(key): with open('../resources/test_config.json') as json_file: main_conf = json.load(json_file) logger.info("reading from main config") return main_conf[key]