Finish up root domain tests, add seperate file for footer tests to allow import later.
This commit is contained in:
parent
401ee636f5
commit
901d37a7a8
44
tests/test_suite/footer_test.py
Executable file
44
tests/test_suite/footer_test.py
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
|
||||||
|
def check_footer_links(driver):
|
||||||
|
# setup wait and grab original tab/window
|
||||||
|
wait = WebDriverWait(driver, 10)
|
||||||
|
main_tab = driver.current_window_handle
|
||||||
|
|
||||||
|
# Try to grab button elements of maintained subdomains
|
||||||
|
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()
|
||||||
|
return False
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
return True
|
@ -6,6 +6,7 @@ from selenium.webdriver.common.by import By
|
|||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions
|
from selenium.webdriver.support import expected_conditions
|
||||||
from robot.api.logger import info, debug, trace, console, error
|
from robot.api.logger import info, debug, trace, console, error
|
||||||
|
from footer_test import check_footer_links
|
||||||
|
|
||||||
|
|
||||||
def check_subdomains(driver):
|
def check_subdomains(driver):
|
||||||
@ -15,8 +16,11 @@ def check_subdomains(driver):
|
|||||||
|
|
||||||
# Try to grab button elements of maintained subdomains
|
# Try to grab button elements of maintained subdomains
|
||||||
try:
|
try:
|
||||||
sites = driver.find_element(
|
site_lists = driver.find_elements(
|
||||||
By.TAG_NAME, "nav").find_elements(By.XPATH, "./div/div")
|
By.TAG_NAME, "nav")
|
||||||
|
sites = []
|
||||||
|
for l in site_lists:
|
||||||
|
sites += l.find_elements(By.XPATH, ".//a")
|
||||||
except:
|
except:
|
||||||
error("Couldn't find the element.")
|
error("Couldn't find the element.")
|
||||||
driver.close()
|
driver.close()
|
||||||
@ -26,8 +30,9 @@ def check_subdomains(driver):
|
|||||||
# Iterate through subdomains
|
# Iterate through subdomains
|
||||||
for e in sites:
|
for e in sites:
|
||||||
try:
|
try:
|
||||||
link_element = e.find_element(By.XPATH, "./a")
|
# link_element = e.find_element(By.XPATH, "./a")
|
||||||
link_element.click()
|
e.click()
|
||||||
|
info(e.text)
|
||||||
wait.until(expected_conditions.number_of_windows_to_be(2))
|
wait.until(expected_conditions.number_of_windows_to_be(2))
|
||||||
for window_handle in driver.window_handles:
|
for window_handle in driver.window_handles:
|
||||||
if window_handle != main_tab:
|
if window_handle != main_tab:
|
||||||
@ -65,13 +70,16 @@ def execute_tests(driver, site_url):
|
|||||||
driver.get(site_url)
|
driver.get(site_url)
|
||||||
info('Page loaded.')
|
info('Page loaded.')
|
||||||
|
|
||||||
# Check all the subdomain buttons work
|
# Check all the buttons work
|
||||||
info('Attempting to click through subdomain buttons...')
|
info('Attempting to click through subdomain buttons...')
|
||||||
if (check_subdomains(driver)):
|
# Check the subdomain buttons
|
||||||
info('Test succeeded.')
|
if (not check_subdomains(driver)):
|
||||||
return True
|
|
||||||
else:
|
|
||||||
info('Test failed.')
|
info('Test failed.')
|
||||||
return False
|
return False
|
||||||
|
# Check the footer buttons
|
||||||
# execute_tests()
|
elif (not check_footer_links(driver)):
|
||||||
|
info('Test failed.')
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
info('Test succeeded.')
|
||||||
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user