spy.urlToTest = original_url try: e = browser2.find_element_by_css_selector(el['s']) spy.logSuccess(el['p'] + " Found", spy.testId, meta) try: spy.urlToTest = spoonful_url e = spy.browser.find_element_by_css_selector(elements[el['i']]['s']) spy.logSuccess("Match Made on Spoonful" + elements[el['i']]['s'], spy.testId, meta) except: if(el['i'] == 1): spy.logMinorFail("Missing Image on Spoonful" + elements[el['i']]['s'], spy.testId, meta ) else: spy.logFail("Missing on Spoonful but present on Family Fun: " + elements[el['i']]['s'], spy.testId, meta) except spy.NoSuchElementException: spy.logNotice(el['p'] + " Missing from Family Fun - <b>Skipping</b> Spoonful Query", spy.testId, meta) if(spy.quitAfter): browser2.quit() except spy.NoSuchElementException: spy.logFail('Hidden Field Not Found to compare URL') #if(spy.quitAfter): # spy.browser.quit() # Spoonful Site
expected_value = '&lid=Calendar/link/032412/See More&lpos=Calendar' selector = '.overlay .text-wrap .in .link a' meta = {'Selector': selector, 'Expected Tag': expected_value} try: overlay_button = spy.browser.find_element_by_css_selector(selector) if(expected_value == overlay_button.get_attribute('name')): spy.logSuccess("Analytic Tag Found in Calendar \"Show More\" Overlay", spy.testId, meta) else: spy.logFail("Analytics tag not found in Calendar \"Show More\" Overlay", spy.testId, meta) except spy.NoSuchElementException: spy.logFail("Analytics tag not found in Calendar \"Show More\" Overlay", spy.testId, meta) # close overlay (for fun?) try: close_button = spy.browser.find_element_by_css_selector('.overlay .close') close_button.click() spy.logNotice("Overlay Closed") except spy.NoSuchElementException: spy.logFail("Could not close overlay") #WRAP SCRIPT spy.complete()
spy.browser.get(spy.urlToTest) # ---------- # # TEST CASES # ---------- # #1. Alt Attributes spy.testId = '1a' try: images = spy.browser.find_elements_by_css_selector('img') spy.logSuccess("Image Markup Found: " + str(len(images)), spy.testId) except spy.NoSuchElementException: spy.logNotice("No Image Markup Found", spy.testId) spy.testId = '1b' try: withAlt = spy.browser.find_elements_by_xpath('//img[@alt]') spy.logNotice("Number of images with alt attributes: " + str(len(withAlt)), spy.testId) except: spy.logFail("No alt attributes found", spy.testId) spy.testId = '1c' altBlank = spy.browser.find_elements_by_xpath("//img[@alt='']") if altBlank: for img in altBlank: spy.logFail("Alt attribute set to blank", spy.testId)