from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from tests.LocatorObjects import Locators RightPanelLocators = Locators.RightPanelLocators() SplashPageLocators = Locators.SplashPageLocators() class RightPanel(object): '''The RightPanel class contains all methods for interacting with the right UI panel.''' def __init__(self, driver): self.driver = driver def dismiss_splash_page(self): '''Clicks the Explore Map & Data button''' element = self.driver.find_element(*SplashPageLocators.EXPLORE_BUTTON) element.click() WebDriverWait(self.driver, 5).until( EC.invisibility_of_element_located( (By.CSS_SELECTOR, '.dialog-shadow'))) def verify_panel_is_open(self, panelName): '''Verifies that the panel specified by panelName is currently open.''' # Get the tool element element = WebDriverWait(self.driver, 5).until( EC.visibility_of_element_located((By.ID, panelName))) # If the tool is currently open, it's class will be 'tool open'
from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from tests.LocatorObjects import Locators CommodityDrawerLocators = Locators.CommodityDrawerLocators() SplashPageLocators = Locators.SplashPageLocators() class CommodityDrawer(object): '''The CommodityDrawer class contains all methods for interacting with the commodity drawers at the bottom of the screen.''' def __init__(self, driver): self.driver = driver def dismiss_splash_page(self): '''Clicks the Explore Map & Data button''' element = self.driver.find_element(*SplashPageLocators.EXPLORE_BUTTON) element.click() WebDriverWait(self.driver, 5).until( EC.invisibility_of_element_located( (By.CSS_SELECTOR, '.dialog-shadow'))) def overview_button_is_correct(self, commodity): # Get the overview button in it's current state overviewBtn = self.driver.find_element( *CommodityDrawerLocators.OVERVIEW_BUTTON) return overviewBtn.get_attribute('innerHTML') == commodity
from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from tests.LocatorObjects import Locators SplashPageLocators = Locators.SplashPageLocators() class BasePage(object): '''Base class to initialise the base page that will be called from all pages''' def __init__(self, driver): self.driver = driver class HomePage(BasePage): '''The Home Page is techincally the only page in AgInsight, as it is a single page application. The Home Page class has methods to verify the UI components are displaying, not actually to test the UI components themselves.''' class SplashPage(BasePage): '''The Splash Page is essentially the Home Page, but we expect that the splash screen will be open at this point.''' def page_is_displayed(self): '''Verified that the splash page is showing''' # Need to wait until the new element has displayed. # Timeout after 10 seconds element = WebDriverWait(self.driver, 5).until( EC.presence_of_element_located((By.ID, 'welcome')))
from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from tests.LocatorObjects import Locators import time HighlightsLocators = Locators.HighlightsLocators() SplashPageLocators = Locators.SplashPageLocators() class Highlights(object): '''The Highlights class contains all methods for interacting with the highlights.''' def __init__(self, driver): self.driver = driver def dismiss_splash_page(self): '''Clicks the Explore Map & Data button''' element = self.driver.find_element(*SplashPageLocators.EXPLORE_BUTTON) element.click() WebDriverWait(self.driver, 5).until( EC.invisibility_of_element_located( (By.CSS_SELECTOR, '.dialog-shadow'))) def highlights_is_open(self): '''Checks if the highlights compoenent is open.''' # Need to wait until the new element has displayed. # Timeout after 3 seconds element = WebDriverWait(self.driver, 3).until( EC.visibility_of_element_located((By.ID, 'highlight')))
from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from tests.LocatorObjects import Locators HeaderLocators = Locators.HeaderLocators() SplashPageLocators = Locators.SplashPageLocators() class Header(object): '''The Header class contains all methods for interacting with the header.''' def __init__(self, driver): self.driver = driver def dismiss_splash_page(self): '''Clicks the Explore Map & Data button''' element = self.driver.find_element(*SplashPageLocators.EXPLORE_BUTTON) element.click() WebDriverWait(self.driver, 5).until( EC.invisibility_of_element_located( (By.CSS_SELECTOR, '.dialog-shadow'))) def new_window_is_open(self, title): '''Method to verify that the disclaimer window has opened in the browser''' # Get the current window and the openend window main_window = self.driver.window_handles[0] # Wait to make sure the second window has opened WebDriverWait(self.driver, 10).until(lambda d: len(d.window_handles) == 2)
from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from tests.LocatorObjects import Locators LeftPanelLocators = Locators.LeftPanelLocators() SplashPageLocators = Locators.SplashPageLocators() class LeftPanel(object): '''The LeftPanel class contains all methods for interacting with the left UI panel.''' def __init__(self, driver): self.driver = driver def dismiss_splash_page(self): '''Clicks the Explore Map & Data button''' #element = self.driver.find_element(*SplashPageLocators.EXPLORE_BUTTON) element = WebDriverWait(self.driver, 5).until( EC.presence_of_element_located(SplashPageLocators.EXPLORE_BUTTON) ) element.click() WebDriverWait(self.driver, 5).until( EC.invisibility_of_element_located((By.CSS_SELECTOR, '.dialog-shadow')) ) def verify_no_commodities_are_opened(self): '''Verifies that no commodity panels are currently opened.''' # Get the menu element element = self.driver.find_element_by_id('menu') isOpen = True
from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from tests.LocatorObjects import Locators TourLocators = Locators.TourLocators() class Tour(object): '''The Tour class contains all methods for interacting with the tour.''' def __init__(self, driver): self.driver = driver def step_title_is_correct(self, className, stepTitle): '''Verify the first step is showing''' # Need to wait until the new element has displayed. # Timeout after 3 seconds element = WebDriverWait(self.driver, 3).until( EC.presence_of_element_located((By.CLASS_NAME, className))) h2Element = element.find_element_by_tag_name('h2') return stepTitle in h2Element.get_attribute('innerHTML') def click_next_button(self): '''Clicks the Tour next button''' element = self.driver.find_element(*TourLocators.NEXT_BUTTON) element.click() def click_close_button(self): '''Clicks the Tour close button''' element = self.driver.find_element(*TourLocators.CLOSE_BUTTON)
from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from tests.LocatorObjects import Locators FooterLocators = Locators.FooterLocators() SplashPageLocators = Locators.SplashPageLocators() class Footer(object): '''The Footer class contains all methods for interacting with the footer.''' def __init__(self, driver): self.driver = driver def dismiss_splash_page(self): '''Clicks the Explore Map & Data button''' element = self.driver.find_element(*SplashPageLocators.EXPLORE_BUTTON) element.click() WebDriverWait(self.driver, 5).until( EC.invisibility_of_element_located((By.CSS_SELECTOR, '.dialog-shadow')) ) def get_current_coord_sys(self): '''Method to return the current coordinate system showing''' element = self.driver.find_element_by_css_selector('.slide-toggle-label') return element.get_attribute('innerHTML') def verify_coord_sys(self, oldCoordSys): '''Method to check the oldCoordSys passed in, is not currently showing''' element = self.driver.find_element_by_css_selector('.slide-toggle-label')