# Generated by Selenium IDE
import pytest
from model.group import Group
from fixture.application import Application



@pytest.fixture
def app(request):
    fixture = Application()
    request.addfinalizer(fixture.destroy)
    return fixture


    # self.driver = webdriver.Chrome()
    # self.driver.implicitly_wait(60)
    # self.vars = {}
  

  
def test_add_group(app):
    app.login(username="admin", password="secret")
    app.create_group(Group(name="it", header="test", footer="header"))
    app.logout()

def test_add_empty_group(app):
    app.login(username="admin", password="secret")
    app.create_group(Group(name="", header="", footer=""))
    app.logout()

  # def logout(self):
  #   # logout
  #   self.driver.find_element(By.LINK_TEXT, "Logout").click()

  # def return_to_groups_page(self):
  #   # return to groups page
  #   self.driver.find_element(By.LINK_TEXT, "group page").click()
  #
  # def create_group(self, group):
  #   self.open_groups_page()
  #   self.driver.find_element(By.NAME, "new").click()
  #   self.driver.find_element(By.NAME, "group_name").click()
  #   # fill group firm
  #   self.driver.find_element(By.NAME, "group_name").send_keys(group.name)
  #   self.driver.find_element(By.NAME, "group_header").click()
  #   self.driver.find_element(By.NAME, "group_header").send_keys(group.header)
  #   self.driver.find_element(By.NAME, "group_footer").click()
  #   self.driver.find_element(By.NAME, "group_footer").send_keys(group.footer)
  #   # submit group creation
  #   self.driver.find_element(By.NAME, "submit").click()
  #
  # def open_groups_page(self):
  #   # open groups page
  #   self.driver.find_element(By.LINK_TEXT, "groups").click()
  #
  # def login(self, username, password):
  #   self.open_home_page()
  #   self.driver.find_element(By.NAME, "user").send_keys(username)
  #   self.driver.find_element(By.NAME, "pass").click()
  #   self.driver.find_element(By.NAME, "pass").send_keys(password)
  #   self.driver.find_element(By.CSS_SELECTOR, "input:nth-child(7)").click()
  #
  # def open_home_page(self):
  #   # open home page
  #   self.driver.get("http://localhost/addressbook/")
  #   self.driver.set_window_size(1048, 1040)
  
