def test_launch_brand_new_session(): drv = SessionDriver() drv.launch(new_session=True) assert not drv.session.is_empty(), 'Session info is empty!' drv.get('https://en.wikipedia.org/wiki/Sevastopol') assert drv.title == 'Sevastopol - Wikipedia', 'Wikipedia page about the legendary city not diplayed.' drv.quit()
def test_session_connect(): session_info = create_session() drv = SessionDriver() drv.client_connect(session_info) drv.get('https://www.breitbart.com/') assert drv.title == 'Breitbart News Network' drv.quit()
def main(): drv = SessionDriver() drv.options.headless = False # start viperdriver in visible mode if drv.session.file_exists(): # if previous session exists, connect to it print('Session file found: ' + drv.session.full_path()) drv.launch(new_session=False) print('Will now navigate to Google in:') x = range(5) for i in x: print('\b', x[-1 - i], sep='', end='', flush=True) sleep(1) print('\n') drv.get('http://google.com') print('Will now close the browser.') for i in range(10): print('.', sep='', end='', flush=True) sleep(0.5) print('\n') drv.quit() else: # if session does not exist, create new one and save to file drv.launch(new_session=True) drv.set_window_size(600, 300) drv.session.save_to_file() print('Exiting. Please start again.')