# 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 TestSignupAllValid():
    def setup_method(self, method):
        self.driver = webdriver.Chrome()
        self.vars = {}

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

    def test_signupAllValid(self):
        self.driver.get("http://localhost/Achievers/HTML/signup.html")
        self.driver.set_window_size(1349, 730)


        # Signup
        self.driver.find_element(By.ID, "Username").click()
        self.driver.find_element(By.ID, "Username").send_keys("testname")
        self.driver.find_element(By.ID, "Email").send_keys("testemail")
        self.driver.find_element(By.ID, "Password").send_keys("testpassword")
        self.driver.find_element(By.ID, "ConfirmPass").send_keys("testpassword")
        self.driver.find_element(By.CSS_SELECTOR, "button").click()


        # Login

        self.driver.find_element(By.ID, "Username").click()
        self.driver.find_element(By.ID, "Username").send_keys("testname")
        self.driver.find_element(By.ID, "Password").send_keys("testpassword")
        self.driver.find_element(By.CSS_SELECTOR, "button").click()
        self.driver.find_element(By.ID, "Password").click()
        self.driver.find_element(By.ID, "Password").click()
        element = self.driver.find_element(By.ID, "Password")
        actions = ActionChains(self.driver)
        actions.double_click(element).perform()
        self.driver.find_element(By.ID, "Password").send_keys(Keys.ENTER)
        self.driver.find_element(By.ID, "Password").send_keys("testpassword")
        self.driver.find_element(By.CSS_SELECTOR, "button").click()
        self.driver.find_element(By.ID, "Password").click()
        self.driver.find_element(By.ID, "Password").send_keys(Keys.ENTER)
        self.driver.find_element(By.ID, "Password").send_keys("testpassword")
        self.driver.find_element(By.CSS_SELECTOR, "button").click()
        self.driver.find_element(By.ID, "Password").click()
        self.driver.find_element(By.ID, "Password").send_keys("test password")
        self.driver.find_element(By.ID, "Password").send_keys(Keys.ENTER)
        self.driver.find_element(By.ID, "Password").click()
        self.driver.find_element(By.ID, "Password").send_keys("testpass")
        self.driver.find_element(By.ID, "Password").send_keys(Keys.ENTER)
        self.driver.find_element(By.CSS_SELECTOR, "button").click()


        element = self.driver.find_element(By.CSS_SELECTOR, "button")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        element = self.driver.find_element(By.CSS_SELECTOR, "body")
        actions = ActionChains(self.driver)
        actions.move_to_element(element, 0, 0).perform()

        # on home page
        self.driver.find_element(By.CSS_SELECTOR, ".header-right").click()
        self.driver.find_element(By.ID, "click").click()
        self.driver.find_element(By.CSS_SELECTOR, ".fa-meh").click()
        self.driver.find_element(By.ID, "tweetBody").click()
        self.driver.find_element(By.ID, "tweetBody").send_keys("new tweet test")
        self.driver.find_element(By.CSS_SELECTOR, ".btn").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".btn")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        element = self.driver.find_element(By.CSS_SELECTOR, "body")
        actions = ActionChains(self.driver)
        actions.move_to_element(element, 0, 0).perform()
        self.driver.find_element(By.ID, "like").click()
        self.driver.find_element(By.CSS_SELECTOR, ".c:nth-child(2) #follow").click()
        self.driver.find_element(By.LINK_TEXT, "Following").click()
        self.driver.find_element(By.LINK_TEXT, "Write Something").click()
        self.driver.find_element(By.CSS_SELECTOR, ".c:nth-child(2) #reply").click()
        self.driver.find_element(By.CSS_SELECTOR, ".c:nth-child(2) #like").click()
