test_main.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ##### IMPORT
  2. import pytest
  3. import logging as log
  4. import time
  5. from selenium import webdriver
  6. from selenium.webdriver.common.by import By
  7. from selenium.webdriver.common.keys import Keys
  8. from selenium.webdriver.support import expected_conditions as EC
  9. from selenium.common.exceptions import TimeoutException
  10. from selenium.webdriver.support.ui import WebDriverWait
  11. from selenium.webdriver.support.ui import Select
  12. from selenium.webdriver.firefox.options import Options
  13. from test_saucedemo import writeInInput
  14. def connexion_saucedemo(username, passwd, arg="--headless"):
  15. log.info("Test du Login avec succès")
  16. options = webdriver.FirefoxOptions()
  17. options.add_argument(arg)
  18. driver = webdriver.Firefox(options=options)
  19. driver.get("https://www.saucedemo.com/")
  20. username = driver.find_element(By.ID, "user-name")
  21. password = driver.find_element(By.ID, "password")
  22. login = driver.find_element(By.ID, "login-button")
  23. writeInInput(inputElement=username, text=username)
  24. writeInInput(password, text=passwd)
  25. login.click()
  26. log.info("")
  27. ##### MANEL
  28. ##### MATTHIEU
  29. ##### TIFF