def refresh(driver): try: driver.refresh() time.sleep(1) print success + "Refreshed Browser at " + ("%s seconds" % (time.time() - start_time)) except: print fail +"Unable to Refresh"
def refresh(driver): try: driver.refresh() time.sleep(1) print success + "Refreshed Browser at " + ("%s seconds" % (time.time() - start_time)) except: print fail + "Unable to Refresh"
def snapshot(driver, image_name): try: time.sleep(5) driver.implicitly_wait(20) driver.save_screenshot('./screens/' + image_name + '.png') print success + "Recorded screenshot " + "'" + image_name + '.png' + "'" + " after " + ("%s seconds" % (time.time() - start_time)) except: print fail + "Unable to take a screenshot" return (time, driver, image_name)
def snapshot(driver, image_name): try: time.sleep(5) driver.implicitly_wait(20) driver.save_screenshot('./screens/' + image_name + '.png') print success + "Recorded screenshot " + "'" + image_name + '.png' + "'" + " after " + ( "%s seconds" % (time.time() - start_time)) except: print fail + "Unable to take a screenshot" return (time, driver, image_name)
def clickRetry (driver, css_selector): try: driver.find_element_by_css_selector(css_selector).click() time.sleep(1) #pause 1 second driver.implicitly_wait(20) print success + "Clicked on <" + css_selector + ">" + " at " + ("%s seconds" % (time.time() - start_time)) except: driver.find_element_by_css_selector(css_selector).click() print fail + "Unable to locate " + css_selector + " and took screenshot of failure" driver.save_screenshot('screens/fails/unable-to-click-' + css_selector + '.png') driver.quit() return (driver, css_selector)
def clickRetry(driver, css_selector): try: driver.find_element_by_css_selector(css_selector).click() time.sleep(1) #pause 1 second driver.implicitly_wait(20) print success + "Clicked on <" + css_selector + ">" except: driver.find_element_by_css_selector(css_selector).click() print fail + "Unable to locate " + css_selector + " and took screenshot of failure" driver.save_screenshot('screens/clickretry-fail.png') driver.quit() return (driver, css_selector)
def clickRetry (driver, css_selector): try: driver.find_element_by_css_selector(css_selector).click() time.sleep(1) #pause 1 second driver.implicitly_wait(20) print success + "Clicked on <" + css_selector + ">" except: driver.find_element_by_css_selector(css_selector).click() print fail + "Unable to locate " + css_selector + " and took screenshot of failure" driver.save_screenshot('screens/clickretry-fail.png') driver.quit() return (driver, css_selector)
def clickRetry(driver, css_selector): try: driver.find_element_by_css_selector(css_selector).click() time.sleep(1) #pause 1 second driver.implicitly_wait(20) print success + "Clicked on <" + css_selector + ">" + " at " + ( "%s seconds" % (time.time() - start_time)) except: driver.find_element_by_css_selector(css_selector).click() print fail + "Unable to locate " + css_selector + " and took screenshot of failure" driver.save_screenshot('screens/fails/unable-to-click-' + css_selector + '.png') driver.quit() return (driver, css_selector)
def pause(seconds): time.sleep(seconds) print success + "Paused Browser for " + str(seconds) + " seconds" return (time)