@ -5,6 +5,8 @@ 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_subdomains ( driver ) :
# setup wait and grab original tab/window
@ -13,9 +15,10 @@ def check_subdomains(driver):
# Try to grab button elements of maintained subdomains
try :
sites = driver . find_element ( By . TAG_NAME , " nav " ) . find_elements ( By . XPATH , " ./div/div " )
sites = driver . find_element (
By . TAG_NAME , " nav " ) . find_elements ( By . XPATH , " ./div/div " )
except :
print ( " Couldn ' t find the element. " )
error ( " Couldn ' t find the element. " )
driver . close ( )
driver . quit ( )
return False
@ -32,34 +35,43 @@ def check_subdomains(driver):
driver . close ( )
driver . switch_to . window ( main_tab )
except :
print ( " Couldn ' t find the element somewhere... " )
error ( " Couldn ' t find the element somewhere... " )
driver . close ( )
driver . quit ( )
return False
return True
def execute_tests ( ) :
def setup_webdriver ( remote_url ) :
# Set up webdriver and necessary variables for later
chrome_options = webdriver . ChromeOptions ( )
print ( ' Attempting to establish connection to remote webdriver... ' )
driver = webdriver . Remote ( command_executor = ' http://192.168.0.202:4444 ' , options = chrome_options )
print ( ' Connection established. ' )
info ( ' Attempting to establish connection to remote webdriver... ' )
driver = webdriver . Remote (
command_executor = remote_url , options = chrome_options )
info ( ' Connection established. ' )
return driver
# Load requested site
print ( ' Attempting to get page... ' )
driver . get ( " https://werefox.cafe " )
print ( ' Page loaded. ' )
# Check all the subdomain buttons work
print ( ' Attempting to click through subdomain buttons... ' )
if ( check_subdomains ( driver ) ) :
print ( ' Test succeeded. ' )
else :
print ( ' Test failed. ' )
def teardown_webdriver ( driver ) :
# Close browser and lean up
driver . close ( )
driver . quit ( )
execute_tests ( )
def execute_tests ( driver , site_url ) :
# Load requested site
info ( ' Attempting to get page... ' )
driver . get ( site_url )
info ( ' Page loaded. ' )
# Check all the subdomain buttons work
info ( ' Attempting to click through subdomain buttons... ' )
if ( check_subdomains ( driver ) ) :
info ( ' Test succeeded. ' )
return True
else :
info ( ' Test failed. ' )
return False
# execute_tests()