# 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 as ec
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class TestConsultaCurso():
  def setup_method(self, method):
    self.driver = webdriver.Chrome('drivers/chrome/94/chromedriver.exe')
    #self.driver.implicitly_wait(3)# espera implicita
    self.vars = {}
  
  def teardown_method(self, method):
    self.driver.quit()
  
  def test_consultaCurso(self):
    self.driver.get("https://iterasys.com.br/plataforma/home/index.php?action=initial")
    self.driver.set_window_size(1456, 876)
    self.driver.find_element(By.ID, "searchtext").click()
    self.driver.find_element(By.ID, "searchtext").send_keys("mantis")
    self.driver.find_element(By.ID, "btn_form_search").click()
    #wait = WebDriverWait(self.driver, 3) # espera explicita
    #wait.until(ec.visibility_of_element_located(By.CSS_SELECTOR))# espera explicita
    self.driver.find_element(By.CSS_SELECTOR, ".comprar").click()
    assert self.driver.find_element(By.CSS_SELECTOR, ".item-title").text == "Mantis"
    self.driver.find_element(By.CSS_SELECTOR, ".checkout-wrap").click()
    assert self.driver.find_element(By.CSS_SELECTOR, "td").text == "Mantis\nR$ 59,99"
  
