# 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



os.environ['WDM_LOG_LEVEL'] = '0'


class TestBatonMenuMobile(TestCase):
    def setUp(self):
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        chrome_options.add_argument('--no-sandbox')
        chrome_options.add_argument('--disable-extensions')
        chrome_options.add_argument('--disable-dev-shm-usage')
        self.driver = webdriver.Chrome(
            ChromeDriverManager().install(),
            options=chrome_options,
        )
        self.driver.set_window_size(480, 600)
        self.driver.implicitly_wait(10)
        self.login()

    def tearDown(self):
        self.driver.quit()

    def login(self):
        self.driver.get('http://localhost:8000/admin')
        username_field = self.driver.find_element_by_id("id_username")
        password_field = self.driver.find_element_by_id("id_password")

# 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_menu_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




os.environ['WDM_LOG_LEVEL'] = '0'


class TestBatonMenuMobile(TestCase):
    def setUp(self):
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        chrome_options.add_argument('--no-sandbox')
        chrome_options.add_argument('--disable-extensions')
        chrome_options.add_argument('--disable-dev-shm-usage')
        self.driver = webdriver.Chrome(
            ChromeDriverManager().install(),
            options=chrome_options,
        )
        self.driver.set_window_size(480, 600)
        self.driver.implicitly_wait(10)
        self.login()

    def tearDown(self):
        self.driver.quit()

    def login(self):
        self.driver.get('http://localhost:8000/admin')
        username_field = self.driver.find_element_by_id("id_username")
        password_field = self.driver.find_element_by_id("id_password")

        button = self.driver.find_element_by_css_selector('input[type=submit]')