# 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 os
import time
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
        except:
            add_button.click()
        time.sleep(10)
        attachments_rows = inlines.find_elements_by_css_selector('.dynamic-attachments')
        self.assertEqual(len(attachments_rows), 3)

    def test_detect_tab_error(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(2)

        # tabs number
        tabs_li = self.driver.find_elements_by_css_selector(
            '.nav-tabs .nav-item')

        tabs_li[3].click()  # change tab attachments
        time.sleep(2)  # fade

        field = self.driver.find_element_by_id("id_attachments-1-caption")
        button = self.driver.find_element_by_css_selector('input[type=submit][name=_continue]')
        time.sleep(1)
        field.send_keys('test')
        time.sleep(1)
        try:
            button.click()
        except:
            button.click()

        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_tabs.py
import os
import time
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

        except:
            add_button.click()
        time.sleep(10)
        attachments_rows = inlines.find_elements_by_css_selector('.dynamic-attachments')
        self.assertEqual(len(attachments_rows), 3)

    def test_detect_tab_error(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(2)

        # tabs number
        tabs_li = self.driver.find_elements_by_css_selector(
            '.nav-tabs .nav-item')

        tabs_li[3].click()  # change tab attachments
        time.sleep(2)  # fade

        field = self.driver.find_element_by_id("id_attachments-1-caption")
        button = self.driver.find_element_by_css_selector('input[type=submit][name=_continue]')
        time.sleep(1)
        field.send_keys('test')
        time.sleep(1)
        try:
            button.click()
        except:
            button.click()

        wait = WebDriverWait(self.driver, 10)

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