#!/usr/bin/python # Necessary imports from selenium.webdriver.common.by import By from robot.api.logger import info, error from footer_test import check_footer_links from shared_methods import load_data, check_buttons def grab_button_elements(driver): # Try to grab button elements of maintained subdomains try: site_lists = driver.find_elements( By.TAG_NAME, "nav") info(site_lists) sites = [] for l in site_lists: sites += l.find_elements(By.XPATH, ".//a") except: error("Couldn't find the element.") return [] return sites def execute_tests(driver, site_url): filepaths = ['/data/homepage/subdomains.yml', '/data/homepage/other.yml'] data = load_data(filepaths) # Load requested site info('Attempting to get page...') driver.get(site_url) info('Page loaded.') # A little bit of setup, grabbing the button elements button_elements = grab_button_elements(driver) info('Attempting to click through subdomain buttons...') # Check all the buttons work if (not check_buttons(driver, data, button_elements)): info('Test failed.') return False # Check the footer buttons elif (not check_footer_links(driver)): info('Test failed.') return False else: info('Test succeeded.') return True