# 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 TestAutoLoginMicrosoft():
  def setup_method(self, method):
    self.driver = webdriver.Chrome()
    self.vars = {}
  
  def teardown_method(self, method):
    self.driver.quit()
  
  def test_autoLoginMicrosoft(self):
    self.driver.get("https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&rver=7.3.6963.0&wp=MBI_SSL&wreply=https%3a%2f%2fwww.microsoft.com%2fen-us%2f%3flc%3d1033&lc=1033&id=74335&aadredir=1")
    WebDriverWait(self.driver, 30000).until(expected_conditions.presence_of_element_located((By.NAME, "loginfmt")))
    self.driver.find_element(By.NAME, "loginfmt").send_keys(self.vars["usernameVar"])
    self.driver.find_element(By.ID, "idSIButton9").click()
    WebDriverWait(self.driver, 30000).until(expected_conditions.presence_of_element_located((By.ID, "usernameError")))
    if self.driver.execute_script("return (id=usernameError)"):
      print(str("No good"))
    else:
      self.driver.find_element(By.NAME, "passwd").send_keys(self.vars["passwordVar"])
      self.driver.find_element(By.ID, "idSIButton9").click()
      WebDriverWait(self.driver, 10000).until(expected_conditions.visibility_of_element_located((By.NAME, "passwd")))
      if self.driver.execute_script("return (name=passwd)"):
        print(str("No good"))
      else:
        self.vars["self.vars["credentialsFound"] | AWS"] = "self.vars["credentialsFound"]"
        print(str("I\'m in!!!!"))
  
