Best Python code snippet using toolium_python
main.py
Source:main.py
...77 print("#" * 50)78 print(err)79 print("#" * 50)80 if abs(t1-time()) > self.search_time:81 self.close_drivers()82 sleep(2)83 self._init_driver()84 sleep(2)85 else:86 print(f"Error occured. Waiting for {self.intrinsic_wait} seconds to proceed. ")87 sleep(self.intrinsic_wait)88 def close_drivers(self):89 self.driver.close()90 self.driver.quit()91 def read_and_write_csv(self):92 now = datetime.now()93 time_now = now.strftime("%d/%m/%Y %H:%M")94 with open(self.save_path, mode='a') as f:95 f = writer(f, delimiter=';', lineterminator='\n')96 if stat(self.save_path).st_size == 0:97 f.writerow([" "] + self.extended_coin_list)98 f.writerow([time_now] + self.search_values)99if __name__ == "__main__":100 coin_freq_scrap = FrequencyScrapper()101 coin_freq_scrap.scrap()102 coin_freq_scrap.close_drivers()...
pytest_fixtures.py
Source:pytest_fixtures.py
...10 return11@pytest.yield_fixture(scope='session', autouse=True)12def session_driver_fixture(request):13 yield None14 DriverManager.close_drivers(scope='session',15 test_name=request.node.name,16 test_passed=request.session.testsfailed == 0)17@pytest.yield_fixture(scope='module', autouse=True)18def module_driver_fixture(request):19 previous_fails = request.session.testsfailed20 yield None21 DriverManager.close_drivers(scope='module',22 test_name=os.path.splitext(os.path.basename(request.node.name))[0],23 test_passed=request.session.testsfailed == previous_fails)24@pytest.yield_fixture(scope='function', autouse=True)25def driver_wrapper(request):26 default_driver_wrapper = DriverManager.connect_default_driver_wrapper()27 yield default_driver_wrapper28 DriverManager.close_drivers(scope='function',29 test_name=request.node.name,...
terrain.py
Source:terrain.py
...9 prepare_pages(world.driver)10@after.all11def close_shop(total):12 print "Total %d of %d scenarios passed!" % (total.scenarios_passed, total.scenarios_ran)13 close_drivers()14def open_drivers():15 world.driver = get_firefox()16 world.driver.set_page_load_timeout(10)17 world.driver.implicitly_wait(10)18 world.driver.maximize_window()19 20def get_firefox():21 # Locate Firefox from the default directory otherwise use FIREFOX_BIN #22 try:23 driver = webdriver.Firefox()24 except Exception:25 my_local_firefox_bin = os.environ.get('FIREFOX_BIN')26 firefox_binary = FirefoxBinary(my_local_firefox_bin)27 driver = webdriver.Firefox(firefox_binary=firefox_binary)28 return driver29def prepare_pages(driver):30 world.home_page = HomePage(driver)31def close_drivers():32 if world.driver:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!