def run(self): StaticVariables.SETUP_START_TIME = time.time() self.finish() set_up() StaticVariables.PROJECT_WORKING_DIRECTORY = project_working_dir StaticVariables.LIBRARY_WORKING_DIRECTORY = library_working_dir static_job_info_file = open(StaticVariables.STATIC_JOB_INFO_PATH, "r") static_job_info = json.loads(static_job_info_file.read()) static_job_info_file.close() is_serverless_driver = static_job_info[StaticVariables.SERVERLESS_DRIVER_FLAG_FN] if is_serverless_driver: frame = inspect.stack()[1] module = inspect.getmodule(frame[0]) os.chdir(StaticVariables.PROJECT_WORKING_DIRECTORY) main_file_path = os.path.relpath(module.__file__) os.chdir(StaticVariables.LIBRARY_WORKING_DIRECTORY) serverless_driver_setup = ServerlessDriverSetup(self.pipelines, self.total_num_functions) serverless_driver_setup.register_driver(main_file_path, self.rel_function_paths) logger.info("Driver Lambda function successfully registered") # command = input("Enter invoke to invoke and other keys to exit: ") command = "" if command == "invoke": logger.info("Driver invoked and starting job execution") serverless_driver_setup.invoke() else: logger.info("The total number of functions is %s" % self.total_num_functions) driver = Driver(self.pipelines, self.total_num_functions) driver.run() tear_down()
def run(self): self.finish() set_up() StaticVariables.PROJECT_WORKING_DIRECTORY = project_working_dir StaticVariables.LIBRARY_WORKING_DIRECTORY = library_working_dir static_job_info_file = open(StaticVariables.STATIC_JOB_INFO_PATH, "r") static_job_info = json.loads(static_job_info_file.read()) static_job_info_file.close() is_serverless_driver = static_job_info[ StaticVariables.SERVERLESS_DRIVER_FLAG_FN] if is_serverless_driver: serverless_driver_setup = ServerlessDriverSetup( self.pipelines, self.total_num_functions) serverless_driver_setup.register_driver() print("Driver Lambda function successfully registered") # command = input("Enter invoke to invoke and other keys to exit: ") command = "123" if command == "invoke": print("Driver invoked and starting job execution") serverless_driver_setup.invoke() else: print("The total number of functions is", self.total_num_functions) driver = Driver(self.pipelines, self.total_num_functions) driver.run() tear_down()
class BaseTest: def setup(self): self.driver = Driver().get_instance() # створення інстансу драйверу self.driver.maximize_window() # розгортання вікна для firefox def teardown(self): Driver().close() # закриття вкладки Driver().quit( ) # закриття драйверу та присвоєння змінній значення за замовчуванням
def lambda_handler(event, _): print("Received event: " + json.dumps(event, indent=2)) print("Starting the driver") with open(StaticVariables.SERVERLESS_PIPELINES_INFO_PATH, 'rb') as f: pipelines = pickle.load(f) total_num_functions = int(os.environ.get("total_num_stages")) driver = Driver(pipelines, total_num_functions, is_serverless=True) driver.run() print("Job executed and Driver shut down")
class BasePage: def __init__(self): self.driver = Driver().get_instance( ) # створення посилання на інстанс драйверу def open(self): """ Відкриття урла з файлу конфігурації """ self.driver.get(conftest.CONFIG["BASE_URL"])
def lambda_handler(event, _): logger.info("Received event: " + json.dumps(event, indent=2)) StaticVariables.SETUP_START_TIME = time.time() logger.info( "*********************Serverless Driver***************************") with open(StaticVariables.SERVERLESS_PIPELINES_INFO_PATH, 'rb') as f: pipelines = pickle.load(f) total_num_functions = int(os.environ.get("total_num_stages")) driver = Driver(pipelines, total_num_functions, is_serverless=True) driver.run() logger.info("Job executed and Driver shut down")
def wrapper(*args, **kwargs): # class_name = args[0].__class__.__name__ # element_name = func.__name__ locator = func(*args, **kwargs) driver = Driver.getInstance() _element = WebDriverWait(driver.get_driver(), 10).until( EC.visibility_of_element_located(locator)) return _element
def main(argv): if "-verbose" in argv or "-v" in argv: verbose = True else: verbose = False if "-loop" in argv or "-l" in argv: loop_connection = True else: loop_connection = False driver = Driver(loop_connection, verbose) driver.load_config() driver.establish_connection() driver.run()
def setup(self): self.driver = Driver().get_instance() # створення інстансу драйверу
def setup(self): self.driver = Driver().get_instance() # створення інстансу драйверу self.driver.maximize_window() # розгортання вікна для firefox
# 判断是否连接 if Dashboard.istempconnect == " 0": # 未连接 Pair = Dashboard().returnTempPage().startpairing().connect(SN=sn) if poco("android.widget.TextView").exists(): # 应该判断paired!是否存在 Pair.next() #返回到主页面 else: print("连接失败") else: #已经连接设备 print("Temp设备已连接") def connectSpO2(self, sn): # 判断是否连接 if Dashboard.isspo2connect == " 0": # 未连接 Pair = Dashboard().returnSpO2().startpairing().connect(SN=sn) if poco("android.widget.TextView").wait( 20).exists(): # 应该判断paired!是否存在 Pair.next() #返回到主页面 else: print("连接失败") else: #已经连接设备 print("SpO2设备已连接") if __name__ == '__main__': Driver().connect_device() Driver().start_app() driver = Connect() driver.connectEcg() Driver().close_app()
def __init__(self, config_, episode_id, ind_exploration_factor, hex_attr_df, hex_distance_df, city_states, neighborhood, popular_bins, q_ind=None, r_table=None, xi_matrix=None, model_testing=False): """ Constructor :param config_: :param episode_id: :param ind_exploration_factor: :param hex_attr_df: :param hex_distance_df: :param dist_df: :param city_states: :param neighborhood: :param popular_bins: :param q_ind: :param r_table: :param xi_matrix: :param model_testing: :return: """ self.config = config_ self.logger = logging.getLogger("cuda_logger") self.episode_id = episode_id self.hex_bins = hex_attr_df['hex_id'] self.city_states = city_states self.model_testing = model_testing # RL parameters RL_parameters = self.config['RL_parameters'] self.num_drivers = RL_parameters['num_drivers'] self.num_strategic_drivers = RL_parameters['num_strategic_drivers'] self.allow_coordination = RL_parameters['allow_coordination'] self.imbalance_threshold = RL_parameters['imbalance_threshold'] self.ind_exploration_factor = ind_exploration_factor self.learning_rate = RL_parameters['learning_rate'] self.discount_factor = RL_parameters['discount_factor'] self.city_states = city_states self.neighborhood = neighborhood self.num_episodes = RL_parameters['num_episodes'] self.ind_episodes = RL_parameters['ind_episodes'] self.reb_episodes = RL_parameters['reb_episodes'] # Create driver tracker and coordination table T = len(self.city_states) S = len(self.hex_bins) self.DT = DriverTracker(config_, episode_id, self.hex_bins, T) # Create drivers self.drivers = {} strategic_drivers = np.random.choice(xrange(self.num_drivers), self.num_strategic_drivers, replace=False) ddm = self.DT.initialize_driver_distribution() for hex_bin in xrange(S): for did in ddm[hex_bin]: if did in strategic_drivers: self.drivers[did] = Driver(self.config, did, hex_bin, True) else: self.drivers[did] = Driver(self.config, did, hex_bin, False) # Create independent Q table self.q_ind = Q_independent(config_, episode_id, self.hex_bins, T, ind_exploration_factor, neighborhood, popular_bins, hex_distance_df, q_ind) # Create R table self.r_table = R_table(config_, episode_id, self.hex_bins, T, self.learning_rate, r_table) # Create Xi Matrix self.xi_matrix = XiMatrix(config_, episode_id, self.hex_bins, T, xi_matrix) # Create ride count matrix for the current episodes self.ride_count_matrix = np.zeros((T, S, S)) self.unsuccessful_wait_matrix = np.zeros((T, S)) # Supply and demand matrix self.supply_matrix = np.zeros((T, S), dtype=int) self.demand_matrix = np.zeros((T, S), dtype=int) # Track episode parameters self.episode_tracker = EpisodeTracker(self.config, episode_id, S, T)
def __init__(self): self.driver = Driver().get_instance( ) # створення посилання на інстанс драйверу
def app(request): global fixture if fixture is None: fixture = Driver(headers={"Accept": "application/json"}, verify=False) return fixture
def llamar_driver(self): self._driver = Driver.getInstance() self._driver.set_up() self._driver.goto_login()
def teardown(self): Driver().close() # закриття вкладки Driver().quit() # закриття драйверу та присвоєння змінній значення за замовчуванням
def setUpClass(cls): cls.d = Driver().get_android_driver()
from driver.driver import Driver from page import shouye from page.hse import HSE, renyuan_Security def ceshi(d): LoginSystem(d).login() d.find_element(*shouye.switch_btn).click() d.find_element(*shouye.HSE).click() d.find_element(*HSE.renyuan_security).click() d.find_element(*renyuan_Security.zidingyi_search).click() d.find_element_by_id("com.gongzhidao.inroad:id/edit_begindate").send_keys( "123456") if __name__ == "__main__": d = Driver().get_android_driver() ceshi(d) ''' if __name__ == "__main__": d = Driver().get_android_driver() mesg = '//*[@text=\'{}\']'.format("网络连接错误") el = WebDriverWait(d, 20, 0.5).until(ec.presence_of_all_elements_located((By.XPATH, mesg))) if el: print(1) else: print(2) '''
def setup_method(self): self.driver = Driver("chrome").get_driver() self.home_page = HomePage(self.driver)
# if a base URL is not specified, scan for it if args['base'] is None: try: url = find_base_url(args['suite']) # if needed, replace the tier if "%(tier)" in url: url = url.replace("%(tier)", args['tier']) args['base'] = url except IOError, e: parser.print_help() print "error:", e sys.exit(1) # start the driver driver = Driver(**args) driver.run() def find_base_url(suite_directory): """Locates the default base URL file, base.url, traversing up from the initial suite directory""" base_file = "base.url" # get the initial path from the suite directory if os.path.isdir(suite_directory): path = suite_directory else: path = os.path.dirname(suite_directory) # find the base URL file
def __init__(self): self.obj_driver = Driver.create_driver(self)
def driver_init(request): """ Instantiate webdriver for selected browser and open homepage """ driver = Driver(URL['Browser']).set_browser(URL['Test_mode']) driver.delete_all_cookies() driver.maximize_window() driver.get(URL['Home_URL']) yield driver driver.close() driver.quit()