2023-01-22 10:02:29 -06:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
# Necessary imports
|
|
|
|
from selenium import webdriver
|
|
|
|
from selenium.webdriver.common.by import By
|
|
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
|
|
from selenium.webdriver.support import expected_conditions
|
|
|
|
from robot.api.logger import info, debug, trace, console, error
|
|
|
|
|
2023-01-26 19:36:12 -06:00
|
|
|
def grab_button_elements(driver):
|
|
|
|
# Try to grab button elements of the footer
|
2023-01-22 10:02:29 -06:00
|
|
|
try:
|
|
|
|
footer_element = driver.find_element(By.TAG_NAME, "footer")
|
|
|
|
sites = footer_element.find_elements(
|
|
|
|
By.XPATH, ".//a")
|
|
|
|
except:
|
|
|
|
error("Couldn't find the element.")
|
|
|
|
driver.close()
|
|
|
|
driver.quit()
|
2023-01-26 19:36:12 -06:00
|
|
|
return {}
|
|
|
|
|
|
|
|
return sites
|
|
|
|
|
|
|
|
def check_footer_links(driver):
|
|
|
|
# setup wait and grab original tab/window
|
|
|
|
wait = WebDriverWait(driver, 10)
|
|
|
|
main_tab = driver.current_window_handle
|
|
|
|
|
|
|
|
sites = grab_button_elements(driver)
|
2023-01-22 10:02:29 -06:00
|
|
|
|
|
|
|
# Iterate through subdomains
|
|
|
|
for e in sites:
|
|
|
|
try:
|
|
|
|
e.click()
|
|
|
|
info(e.text)
|
|
|
|
wait.until(expected_conditions.number_of_windows_to_be(2))
|
|
|
|
for window_handle in driver.window_handles:
|
|
|
|
if window_handle != main_tab:
|
|
|
|
driver.switch_to.window(window_handle)
|
|
|
|
driver.close()
|
|
|
|
driver.switch_to.window(main_tab)
|
|
|
|
except:
|
|
|
|
error("Couldn't find the element somewhere...")
|
|
|
|
driver.close()
|
|
|
|
driver.quit()
|
|
|
|
return False
|
|
|
|
|
2023-01-26 19:36:12 -06:00
|
|
|
return True
|