def query_google(keywords): print("Loading Firefox driver...") driver, waiter, selector, download_path = init() print("Fetching google front page...") driver.get("https://www.google.com") print("Taking a screenshot...") waiter.shoot("frontpage") print("Typing query string...") selector.get_and_clear("input[type=text]").send_keys(keywords) print("Hitting Enter...") # selector.get("button").click() ids = driver.find_elements_by_xpath("//input[@type='submit']") for ii in ids: ii.click() break print("Waiting for results to come back...") waiter.until_display("#ires") print print("The top search result is:") print print(' "{}"'.format(selector.get("#ires a").text)) print
def query_vecka(keywords): print("Loading Firefox driver...") driver, waiter, selector, datapath = init() print("Fetching vecka.nu front page...") driver.get("http://vecka.nu") print("Taking a screenshot...") waiter.shoot("frontpage") print("Get week") print("The current week is %s" % selector.get("time").text)
def query_google(keywords): print "Loading Firefox driver..." driver, waiter, selector = init() print "Fetching google front page..." driver.get("http://google.com") print "Taking a screenshot..." waiter.shoot("frontpage") print "Typing query string..." selector.get_and_clear("input[type=text]").send_keys(keywords) print "Hitting Enter..." selector.get("button").click() print "Waiting for results to come back..." waiter.until_display("#ires") print print "The top search result is:" print print ' "{}"'.format(selector.get("#ires a").text) print
def query_google(keywords): print("Loading Firefox driver...") driver, waiter, selector, datapath = init() print("Fetching google front page...") driver.get("http://google.com") print("Taking a screenshot...") waiter.shoot("frontpage") print("Typing query string...") selector.get_and_clear("input[type=text]").send_keys(keywords) print("Hitting Enter...") selector.get("input[type=submit]").click() print("Waiting for results to come back...") waiter.until_display("#ires") print print("The top search result is:") print print(' "{}"'.format(selector.get("#ires a").text)) print
HDD_address = 'https://ssebusiness.co.uk/Restricted/MyAccount/Reporting/HHDataExtract.aspx' uname = 'burohappoldcvd' pword = 'Sunshine17' # Azure Blob Storage Configuration accountname = 'bhenergydatastore' accountkey = 'nLZvyCTJXknUWeCeZSG2vOPA7uix4cpjLd4YIoPzTJTIwBoCUl6xIINTZySD6uSoTfoB2xiOW6wAP4qsiurm1w==' container_name = 'burohappoldukmeters' blob_client = azureblob.BlockBlobService(account_name=accountname, account_key=accountkey) print("Loading Firefox driver...") driver, waiter, selector, datapath = init() # Open page and login print("Getting login page...") driver.get(login_address) sleep(5) print("Logging in...") login(driver, uname, pword) if args.start_date and args.end_date: start_date = datetime.strptime(args.start_date, '%d/%m/%Y') end_date = datetime.strptime(args.end_date, '%d/%m/%Y') day = timedelta(days=1) while start_date <= end_date: get_process_post_data(start_date)
def run_test(info_dict): num_passed = passed = 0 num_failed = failed = 0 print(c.OKBLUE + "Loading Firefox driver...", end=' ') driver, waiter, selector, datapath = init() print("...done." + c.ENDC) try: target = info_dict['target'] except NameError or KeyError: print(c.FAIL + "Error: The reqiured 'target' element could not be found." + c.ENDC) return 1 try: base = target['base-url'] base_url = os.environ.get('BASE_URL', base) except NameError or KeyError: print(c.FAIL + "Error: The reqiured 'base-url' element could not be found." + c.ENDC) return 1 try: site_description = target['site-description'] except NameError or KeyError: print( c.FAIL + "Error: The reqiured 'site-description' element could not be found." + c.ENDC) return 1 # If authentication is reqiured...do it here. try: auth = target['authentication'] except: print( c.OKBLUE + "Authentication is not specified. Tests will run without login.") print(c.ENDC) else: do_authentication(driver, auth, base_url) try: tests = target['tests'] except NameError or KeyError: print(c.FAIL + "Error: The reqiured 'tests' element could not be found." + c.ENDC) return 1 print(c.OKBLUE + "Begin processing tests for '{0}' with a base URL of '{1}'.".format( site_description, base_url) + c.ENDC) grandTotalTime = 0 for test in tests: description = test['description'] full_url = base_url + test['url'] print(" ") print(c.OKBLUE + "{} ---------- ".format(description)) print("Fetching '{}'...".format(full_url), end=' ') try: start = int(round(time.time() * 1000)) driver.get(full_url) finish = int(round(time.time() * 1000)) totalTime = finish - start grandTotalTime += totalTime print("...done. " + c.ENDC + c.HIGHLIGHT) print(" Total load time: {} seconds".format(totalTime / 1000.) + c.OKBLUE) waiter.shoot(site_description + " - " + description) print(c.ENDC) if 'fail' in test: print(c.FAIL + "Forced Failure!!! {} ".format(test['fail']) + c.ENDC) num_failed += 1 elif 'match' in test: for a_match in test['match']: (passed, failed) = do_match(driver, a_match, full_url) num_passed += passed num_failed += failed except: print(c.FAIL) print("Unexpected error:", sys.exc_info()[0]) print(c.ENDC) num_failed += 1 raise msg = "All '{0}' tests are complete with {1} passed and {2} failed and total load time of ".format( site_description, num_passed, num_failed) msg += c.HIGHLIGHT + "{} seconds.".format(grandTotalTime / 1000.) print(c.OKBLUE + c.HEADER) print(msg) print(c.ENDC) driver.quit() if num_failed > 0: send_notification_via_smtp(msg, num_failed) return num_failed