from django.test import TestCase

# Create your tests here.
# Generated by Selenium IDE
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities


class TestFRfinal():
    def setup_method(self, method):
        self.driver = webdriver.Firefox()
        self.vars = {}

    def teardown_method(self, method):
        self.driver.quit()

    def test_f0(self):
        # Test name: f0 Testing navigation menu
        # Step # | name | target | value
        # 1 | open | / |
        self.driver.get("http://127.0.0.1:8000/")
        # 2 | setWindowSize | 854x704 |
        self.driver.set_window_size(854, 704)
        # 3 | click | linkText=Home |
        self.driver.find_element(By.LINK_TEXT, "Home").click()
        # 4 | click | linkText=Eligibility |
        self.driver.find_element(By.LINK_TEXT, "Eligibility").click()
        # 5 | click | linkText=About |
        self.driver.find_element(By.LINK_TEXT, "About").click()
        # 6 | click | linkText=Home |
        self.driver.find_element(By.LINK_TEXT, "Home").click()
        # 7 | click | linkText=Am I eligible? |
        self.driver.find_element(By.LINK_TEXT, "Am I eligible?").click()
        # 8 | click | linkText=About |
        self.driver.find_element(By.LINK_TEXT, "About").click()
        # 9 | click | linkText=Eligibility |
        self.driver.find_element(By.LINK_TEXT, "Eligibility").click()
        # 10 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 11 | close |  |
        self.driver.close()

    def test_f1(self):
        # Test name: f1 Testing dropdown menus and integer selector with an ineligible user
        # Step # | name | target | value
        # 1 | open | / |
        self.driver.get("http://127.0.0.1:8000/")
        # 2 | setWindowSize | 854x704 |
        self.driver.set_window_size(854, 704)
        # 3 | click | linkText=Am I eligible? |
        self.driver.find_element(By.LINK_TEXT, "Am I eligible?").click()
        # 4 | click | id=id_home_state |
        self.driver.find_element(By.ID, "id_home_state").click()
        # 5 | select | id=id_home_state | label=INDIANA
        dropdown = self.driver.find_element(By.ID, "id_home_state")
        dropdown.find_element(By.XPATH, "//option[. = 'INDIANA']").click()
        # 6 | click | css=#id_home_state > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_home_state > option:nth-child(2)").click()
        # 7 | click | id=id_work_state |
        self.driver.find_element(By.ID, "id_work_state").click()
        # 8 | select | id=id_work_state | label=INDIANA
        dropdown = self.driver.find_element(By.ID, "id_work_state")
        dropdown.find_element(By.XPATH, "//option[. = 'INDIANA']").click()
        # 9 | click | css=#id_work_state > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_work_state > option:nth-child(2)").click()
        # 10 | type | id=id_age | 1
        self.driver.find_element(By.ID, "id_age").send_keys("1")
        # 11 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 12 | click | id=id_essential |
        self.driver.find_element(By.ID, "id_essential").click()
        # 13 | select | id=id_essential | label=Yes
        dropdown = self.driver.find_element(By.ID, "id_essential")
        dropdown.find_element(By.XPATH, "//option[. = 'Yes']").click()
        # 14 | click | css=#id_essential > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_essential > option:nth-child(2)").click()
        # 15 | click | id=id_vaccine_group |
        self.driver.find_element(By.ID, "id_vaccine_group").click()
        # 16 | select | id=id_vaccine_group | label=A
        dropdown = self.driver.find_element(By.ID, "id_vaccine_group")
        dropdown.find_element(By.XPATH, "//option[. = 'A']").click()
        # 17 | click | css=#id_vaccine_group > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_vaccine_group > option:nth-child(2)").click()
        # 18 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()

    def test_f2(self):
        # Test name: f2 Testing input with an eligible user
        # Step # | name | target | value
        # 1 | open | / |
        self.driver.get("http://127.0.0.1:8000/")
        # 2 | setWindowSize | 854x704 |
        self.driver.set_window_size(854, 704)
        # 3 | click | linkText=Am I eligible? |
        self.driver.find_element(By.LINK_TEXT, "Am I eligible?").click()
        # 4 | click | id=id_home_state |
        self.driver.find_element(By.ID, "id_home_state").click()
        # 5 | select | id=id_home_state | label=KENTUCKY
        dropdown = self.driver.find_element(By.ID, "id_home_state")
        dropdown.find_element(By.XPATH, "//option[. = 'KENTUCKY']").click()
        # 6 | click | css=#id_home_state > option:nth-child(3) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_home_state > option:nth-child(3)").click()
        # 7 | click | id=id_work_state |
        self.driver.find_element(By.ID, "id_work_state").click()
        # 8 | select | id=id_work_state | label=INDIANA
        dropdown = self.driver.find_element(By.ID, "id_work_state")
        dropdown.find_element(By.XPATH, "//option[. = 'INDIANA']").click()
        # 9 | click | css=#id_work_state > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_work_state > option:nth-child(2)").click()
        # 10 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 11 | type | id=id_age | 16
        self.driver.find_element(By.ID, "id_age").send_keys("16")
        # 12 | click | id=id_essential |
        self.driver.find_element(By.ID, "id_essential").click()
        # 13 | select | id=id_essential | label=Yes
        dropdown = self.driver.find_element(By.ID, "id_essential")
        dropdown.find_element(By.XPATH, "//option[. = 'Yes']").click()
        # 14 | click | css=#id_essential > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_essential > option:nth-child(2)").click()
        # 15 | click | id=id_vaccine_group |
        self.driver.find_element(By.ID, "id_vaccine_group").click()
        # 16 | select | id=id_vaccine_group | label=Unknown
        dropdown = self.driver.find_element(By.ID, "id_vaccine_group")
        dropdown.find_element(By.XPATH, "//option[. = 'Unknown']").click()
        # 17 | click | css=option:nth-child(6) |
        self.driver.find_element(By.CSS_SELECTOR, "option:nth-child(6)").click()
        # 18 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()

    def test_f3(self):
        # Test name: f3 Testing response for incomplete input
        # Step # | name | target | value
        # 1 | open | / |
        self.driver.get("http://127.0.0.1:8000/")
        # 2 | setWindowSize | 854x704 |
        self.driver.set_window_size(854, 704)
        # 3 | click | linkText=Am I eligible? |
        self.driver.find_element(By.LINK_TEXT, "Am I eligible?").click()
        # 4 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 5 | type | id=id_age | 16
        self.driver.find_element(By.ID, "id_age").send_keys("16")
        # 6 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 7 | click | id=id_home_state |
        self.driver.find_element(By.ID, "id_home_state").click()
        # 8 | select | id=id_home_state | label=INDIANA
        dropdown = self.driver.find_element(By.ID, "id_home_state")
        dropdown.find_element(By.XPATH, "//option[. = 'INDIANA']").click()
        # 9 | click | css=#id_home_state > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_home_state > option:nth-child(2)").click()
        # 10 | click | id=id_work_state |
        self.driver.find_element(By.ID, "id_work_state").click()
        # 11 | select | id=id_work_state | label=INDIANA
        dropdown = self.driver.find_element(By.ID, "id_work_state")
        dropdown.find_element(By.XPATH, "//option[. = 'INDIANA']").click()
        # 12 | click | css=#id_work_state > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_work_state > option:nth-child(2)").click()
        # 13 | click | id=id_essential |
        self.driver.find_element(By.ID, "id_essential").click()
        # 14 | select | id=id_essential | label=Yes
        dropdown = self.driver.find_element(By.ID, "id_essential")
        dropdown.find_element(By.XPATH, "//option[. = 'Yes']").click()
        # 15 | click | css=#id_essential > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_essential > option:nth-child(2)").click()
        # 16 | click | id=id_vaccine_group |
        self.driver.find_element(By.ID, "id_vaccine_group").click()
        # 17 | select | id=id_vaccine_group | label=A
        dropdown = self.driver.find_element(By.ID, "id_vaccine_group")
        dropdown.find_element(By.XPATH, "//option[. = 'A']").click()
        # 18 | click | css=#id_vaccine_group > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_vaccine_group > option:nth-child(2)").click()
        # 19 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()

    def test_f4(self):
        # Test name: f4 Testing response for age = 0
        # Step # | name | target | value
        # 1 | open | / |
        self.driver.get("http://127.0.0.1:8000/")
        # 2 | setWindowSize | 854x704 |
        self.driver.set_window_size(854, 704)
        # 3 | click | linkText=Am I eligible? |
        self.driver.find_element(By.LINK_TEXT, "Am I eligible?").click()
        # 4 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 5 | click | id=id_home_state |
        self.driver.find_element(By.ID, "id_home_state").click()
        # 6 | select | id=id_home_state | label=KENTUCKY
        dropdown = self.driver.find_element(By.ID, "id_home_state")
        dropdown.find_element(By.XPATH, "//option[. = 'KENTUCKY']").click()
        # 7 | click | css=#id_home_state > option:nth-child(3) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_home_state > option:nth-child(3)").click()
        # 8 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 9 | click | id=id_work_state |
        self.driver.find_element(By.ID, "id_work_state").click()
        # 10 | select | id=id_work_state | label=INDIANA
        dropdown = self.driver.find_element(By.ID, "id_work_state")
        dropdown.find_element(By.XPATH, "//option[. = 'INDIANA']").click()
        # 11 | click | css=#id_work_state > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_work_state > option:nth-child(2)").click()
        # 12 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 13 | type | id=id_age | 0
        self.driver.find_element(By.ID, "id_age").send_keys("0")
        # 14 | click | id=id_essential |
        self.driver.find_element(By.ID, "id_essential").click()
        # 15 | click | css=p:nth-child(5) |
        self.driver.find_element(By.CSS_SELECTOR, "p:nth-child(5)").click()
        # 16 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 17 | click | id=id_essential |
        self.driver.find_element(By.ID, "id_essential").click()
        # 18 | select | id=id_essential | label=Yes
        dropdown = self.driver.find_element(By.ID, "id_essential")
        dropdown.find_element(By.XPATH, "//option[. = 'Yes']").click()
        # 19 | click | css=#id_essential > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_essential > option:nth-child(2)").click()
        # 20 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 21 | click | id=id_vaccine_group |
        self.driver.find_element(By.ID, "id_vaccine_group").click()
        # 22 | select | id=id_vaccine_group | label=A
        dropdown = self.driver.find_element(By.ID, "id_vaccine_group")
        dropdown.find_element(By.XPATH, "//option[. = 'A']").click()
        # 23 | click | css=#id_vaccine_group > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_vaccine_group > option:nth-child(2)").click()
        # 24 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 25 | type | id=id_age | 1
        self.driver.find_element(By.ID, "id_age").send_keys("1")
        # 26 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 27 | type | id=id_age | 2
        self.driver.find_element(By.ID, "id_age").send_keys("2")
        # 28 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 29 | doubleClick | id=id_age |
        element = self.driver.find_element(By.ID, "id_age")
        actions = ActionChains(self.driver)
        actions.double_click(element).perform()
        # 30 | type | id=id_age | 3
        self.driver.find_element(By.ID, "id_age").send_keys("3")
        # 31 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 32 | type | id=id_age | 4
        self.driver.find_element(By.ID, "id_age").send_keys("4")
        # 33 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 34 | doubleClick | id=id_age |
        element = self.driver.find_element(By.ID, "id_age")
        actions = ActionChains(self.driver)
        actions.double_click(element).perform()
        # 35 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 36 | close |  |
        self.driver.close()

    def test_f5(self):
        # Test name: f5 Testing response to age > 120
        # Step # | name | target | value
        # 1 | open | / |
        self.driver.get("http://127.0.0.1:8000/")
        # 2 | setWindowSize | 854x704 |
        self.driver.set_window_size(854, 704)
        # 3 | click | linkText=Am I eligible? |
        self.driver.find_element(By.LINK_TEXT, "Am I eligible?").click()
        # 4 | click | id=id_vaccine_group |
        self.driver.find_element(By.ID, "id_vaccine_group").click()
        # 5 | select | id=id_vaccine_group | label=A
        dropdown = self.driver.find_element(By.ID, "id_vaccine_group")
        dropdown.find_element(By.XPATH, "//option[. = 'A']").click()
        # 6 | click | css=#id_vaccine_group > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_vaccine_group > option:nth-child(2)").click()
        # 7 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 8 | click | id=id_essential |
        self.driver.find_element(By.ID, "id_essential").click()
        # 9 | select | id=id_essential | label=Yes
        dropdown = self.driver.find_element(By.ID, "id_essential")
        dropdown.find_element(By.XPATH, "//option[. = 'Yes']").click()
        # 10 | click | css=#id_essential > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_essential > option:nth-child(2)").click()
        # 11 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 12 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 13 | type | id=id_age | 130
        self.driver.find_element(By.ID, "id_age").send_keys("130")
        # 14 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 15 | click | css=p:nth-child(3) |
        self.driver.find_element(By.CSS_SELECTOR, "p:nth-child(3)").click()
        # 16 | click | id=id_work_state |
        self.driver.find_element(By.ID, "id_work_state").click()
        # 17 | select | id=id_work_state | label=INDIANA
        dropdown = self.driver.find_element(By.ID, "id_work_state")
        dropdown.find_element(By.XPATH, "//option[. = 'INDIANA']").click()
        # 18 | click | css=#id_work_state > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_work_state > option:nth-child(2)").click()
        # 19 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 20 | click | id=id_home_state |
        self.driver.find_element(By.ID, "id_home_state").click()
        # 21 | select | id=id_home_state | label=KENTUCKY
        dropdown = self.driver.find_element(By.ID, "id_home_state")
        dropdown.find_element(By.XPATH, "//option[. = 'KENTUCKY']").click()
        # 22 | click | css=#id_home_state > option:nth-child(3) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_home_state > option:nth-child(3)").click()
        # 23 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()
        # 24 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 25 | type | id=id_age | 119
        self.driver.find_element(By.ID, "id_age").send_keys("119")
        # 26 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()

    def test_f6(self):
        # Test name: f6 Testing response to eligible user who is not essential
        # Step # | name | target | value
        # 1 | open | / |
        self.driver.get("http://127.0.0.1:8000/")
        # 2 | setWindowSize | 854x704 |
        self.driver.set_window_size(854, 704)
        # 3 | click | linkText=Am I eligible? |
        self.driver.find_element(By.LINK_TEXT, "Am I eligible?").click()
        # 4 | click | id=id_home_state |
        self.driver.find_element(By.ID, "id_home_state").click()
        # 5 | select | id=id_home_state | label=KENTUCKY
        dropdown = self.driver.find_element(By.ID, "id_home_state")
        dropdown.find_element(By.XPATH, "//option[. = 'KENTUCKY']").click()
        # 6 | click | css=#id_home_state > option:nth-child(3) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_home_state > option:nth-child(3)").click()
        # 7 | click | id=id_work_state |
        self.driver.find_element(By.ID, "id_work_state").click()
        # 8 | select | id=id_work_state | label=KENTUCKY
        dropdown = self.driver.find_element(By.ID, "id_work_state")
        dropdown.find_element(By.XPATH, "//option[. = 'KENTUCKY']").click()
        # 9 | click | css=#id_work_state > option:nth-child(3) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_work_state > option:nth-child(3)").click()
        # 10 | type | id=id_age | 21
        self.driver.find_element(By.ID, "id_age").send_keys("21")
        # 11 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 12 | click | id=id_essential |
        self.driver.find_element(By.ID, "id_essential").click()
        # 13 | select | id=id_essential | label=No
        dropdown = self.driver.find_element(By.ID, "id_essential")
        dropdown.find_element(By.XPATH, "//option[. = 'No']").click()
        # 14 | click | css=#id_essential > option:nth-child(3) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_essential > option:nth-child(3)").click()
        # 15 | click | id=id_vaccine_group |
        self.driver.find_element(By.ID, "id_vaccine_group").click()
        # 16 | select | id=id_vaccine_group | label=D
        dropdown = self.driver.find_element(By.ID, "id_vaccine_group")
        dropdown.find_element(By.XPATH, "//option[. = 'D']").click()
        # 17 | click | css=option:nth-child(5) |
        self.driver.find_element(By.CSS_SELECTOR, "option:nth-child(5)").click()
        # 18 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()

    def test_f7(self):
        # Test name: f7 Testing that choices clear when navigation buttons are chosen
        # Step # | name | target | value
        # 1 | open | / |
        self.driver.get("http://127.0.0.1:8000/")
        # 2 | setWindowSize | 854x704 |
        self.driver.set_window_size(854, 704)
        # 3 | click | linkText=Am I eligible? |
        self.driver.find_element(By.LINK_TEXT, "Am I eligible?").click()
        # 4 | click | id=id_home_state |
        self.driver.find_element(By.ID, "id_home_state").click()
        # 5 | select | id=id_home_state | label=INDIANA
        dropdown = self.driver.find_element(By.ID, "id_home_state")
        dropdown.find_element(By.XPATH, "//option[. = 'INDIANA']").click()
        # 6 | click | css=#id_home_state > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_home_state > option:nth-child(2)").click()
        # 7 | click | linkText=About |
        self.driver.find_element(By.LINK_TEXT, "About").click()
        # 8 | click | linkText=Home |
        self.driver.find_element(By.LINK_TEXT, "Home").click()
        # 9 | click | linkText=Eligibility |
        self.driver.find_element(By.LINK_TEXT, "Eligibility").click()
        # 10 | click | id=id_home_state |
        self.driver.find_element(By.ID, "id_home_state").click()
        # 11 | select | id=id_home_state | label=KENTUCKY
        dropdown = self.driver.find_element(By.ID, "id_home_state")
        dropdown.find_element(By.XPATH, "//option[. = 'KENTUCKY']").click()
        # 12 | click | css=#id_home_state > option:nth-child(3) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_home_state > option:nth-child(3)").click()
        # 13 | click | id=id_work_state |
        self.driver.find_element(By.ID, "id_work_state").click()
        # 14 | select | id=id_work_state | label=INDIANA
        dropdown = self.driver.find_element(By.ID, "id_work_state")
        dropdown.find_element(By.XPATH, "//option[. = 'INDIANA']").click()
        # 15 | click | css=#id_work_state > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_work_state > option:nth-child(2)").click()
        # 16 | type | id=id_age | 1
        self.driver.find_element(By.ID, "id_age").send_keys("1")
        # 17 | click | id=id_age |
        self.driver.find_element(By.ID, "id_age").click()
        # 18 | click | id=id_essential |
        self.driver.find_element(By.ID, "id_essential").click()
        # 19 | select | id=id_essential | label=Yes
        dropdown = self.driver.find_element(By.ID, "id_essential")
        dropdown.find_element(By.XPATH, "//option[. = 'Yes']").click()
        # 20 | click | css=#id_essential > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_essential > option:nth-child(2)").click()
        # 21 | click | id=id_vaccine_group |
        self.driver.find_element(By.ID, "id_vaccine_group").click()
        # 22 | select | id=id_vaccine_group | label=A
        dropdown = self.driver.find_element(By.ID, "id_vaccine_group")
        dropdown.find_element(By.XPATH, "//option[. = 'A']").click()
        # 23 | click | css=#id_vaccine_group > option:nth-child(2) |
        self.driver.find_element(By.CSS_SELECTOR, "#id_vaccine_group > option:nth-child(2)").click()
        # 24 | click | css=.button |
        self.driver.find_element(By.CSS_SELECTOR, ".button").click()