# Path: testapp/app/app/tests/utils.py
# class element_has_css_class(object):
#     """An expectation for checking that an element has a particular css class.
#     locator - used to find the element
#     returns the WebElement once it has the particular css class
#     """
# 
#     def __init__(self, locator, css_class):
#         self.locator = locator
#         self.css_class = css_class
# 
#     def __call__(self, driver):
#         element = driver.find_element(*self.locator)   # Finding the referenced element
#         if self.css_class in element.get_attribute("class"):
#             return element
#         else:
#             return False


import time
import os
from django.test import TestCase
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from .utils import element_has_css_class
        self.assertEqual(user_dropdown_menu[1].get_attribute('innerHTML'),
                         'Documentation')
        self.assertEqual(user_dropdown_menu[2].get_attribute('innerHTML'),
                         'Change password')
        self.assertEqual(user_dropdown_menu[3].get_attribute('innerHTML'),
                         'Log out')

    def test_content(self):
        # Wait until baton is ready
        wait = WebDriverWait(self.driver, 10)
        wait.until(element_has_css_class((By.TAG_NAME, 'body'), "baton-ready"))
        time.sleep(1)

        # page title
        page_title = self.driver.find_element_by_css_selector(
            "#content h1")
        self.assertEqual(page_title.get_attribute('innerHTML'), 'Baton administration')
        self.assertEqual(page_title.is_displayed(), True)

        # recent actions
        recent_actions = self.driver.find_element_by_id('recent-actions-module')
        self.assertEqual(recent_actions.is_displayed(), True)

        modules = self.driver.find_elements_by_css_selector(
            "#content-main .module")
        self.assertEqual(len(modules), 3)

    def test_footer(self):
        # Wait until baton is ready
        wait = WebDriverWait(self.driver, 10)

# Path: testapp/app/app/tests/utils.py
# class element_has_css_class(object):
#     """An expectation for checking that an element has a particular css class.
#     locator - used to find the element
#     returns the WebElement once it has the particular css class
#     """
# 
#     def __init__(self, locator, css_class):
#         self.locator = locator
#         self.css_class = css_class
# 
#     def __call__(self, driver):
#         element = driver.find_element(*self.locator)   # Finding the referenced element
#         if self.css_class in element.get_attribute("class"):
#             return element
#         else:
#             return False


# Path: testapp/app/app/tests/test_e2e_index_mobile.py
import time
import os
from django.test import TestCase
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from .utils import element_has_css_class

        self.assertEqual(user_dropdown_menu[1].get_attribute('innerHTML'),
                         'Documentation')
        self.assertEqual(user_dropdown_menu[2].get_attribute('innerHTML'),
                         'Change password')
        self.assertEqual(user_dropdown_menu[3].get_attribute('innerHTML'),
                         'Log out')

    def test_content(self):
        # Wait until baton is ready
        wait = WebDriverWait(self.driver, 10)
        wait.until(element_has_css_class((By.TAG_NAME, 'body'), "baton-ready"))
        time.sleep(1)

        # page title
        page_title = self.driver.find_element_by_css_selector(
            "#content h1")
        self.assertEqual(page_title.get_attribute('innerHTML'), 'Baton administration')
        self.assertEqual(page_title.is_displayed(), True)

        # recent actions
        recent_actions = self.driver.find_element_by_id('recent-actions-module')
        self.assertEqual(recent_actions.is_displayed(), True)

        modules = self.driver.find_elements_by_css_selector(
            "#content-main .module")
        self.assertEqual(len(modules), 3)

    def test_footer(self):
        # Wait until baton is ready
        wait = WebDriverWait(self.driver, 10)

        wait.until(element_has_css_class((By.TAG_NAME, 'body'), "baton-ready"))