|
@@ -0,0 +1,97 @@
|
|
|
+##### IMPORT
|
|
|
+import pytest
|
|
|
+import logging as log
|
|
|
+import time
|
|
|
+from selenium import webdriver
|
|
|
+from selenium.webdriver.common.by import By
|
|
|
+from selenium.webdriver.common.keys import Keys
|
|
|
+from selenium.webdriver.support import expected_conditions as EC
|
|
|
+from selenium.common.exceptions import TimeoutException
|
|
|
+from selenium.webdriver.support.ui import WebDriverWait
|
|
|
+from selenium.webdriver.support.ui import Select
|
|
|
+from selenium.webdriver.firefox.options import Options
|
|
|
+from test_saucedemo import writeInInput
|
|
|
+
|
|
|
+
|
|
|
+def connexion_saucedemo(username, passwd):
|
|
|
+ log.info("Test du Login avec succès")
|
|
|
+ options = webdriver.FirefoxOptions()
|
|
|
+ options.add_argument("--headless")
|
|
|
+
|
|
|
+ driver = webdriver.Firefox(options=options)
|
|
|
+
|
|
|
+ driver.get("https://www.saucedemo.com/")
|
|
|
+
|
|
|
+ username = driver.find_element(By.ID, "user-name")
|
|
|
+ password = driver.find_element(By.ID, "password")
|
|
|
+ login = driver.find_element(By.ID, "login-button")
|
|
|
+
|
|
|
+ writeInInput(inputElement=username, text=username)
|
|
|
+ writeInInput(password, text=passwd)
|
|
|
+ login.click()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+##### MANEL
|
|
|
+
|
|
|
+
|
|
|
+##### MATTHIEU
|
|
|
+
|
|
|
+def go_to_checkout():
|
|
|
+ checkout = driver.find_element(By.CSS_SELECTOR, "#checkout")
|
|
|
+ checkout.click()
|
|
|
+
|
|
|
+@pytest.mark.skip("Je veux pas le faire")
|
|
|
+def test_affichage_Checkout():
|
|
|
+ log.info("Test de la redirection sur la page de Checkout")
|
|
|
+
|
|
|
+ #connexion Swag Labs
|
|
|
+ #connexion_saucedemo("standard_user", "secret_sauce", "") --A DEBUGG
|
|
|
+
|
|
|
+ options = webdriver.FirefoxOptions()
|
|
|
+ options.add_argument("--headless")
|
|
|
+
|
|
|
+ driver = webdriver.Firefox(options=options)
|
|
|
+ driver.get("https://www.saucedemo.com/")
|
|
|
+ assert (
|
|
|
+ driver.current_url == "https://www.saucedemo.com/"
|
|
|
+ ), "Nous ne somme pas sur la bonne page"
|
|
|
+
|
|
|
+ username = driver.find_element(By.ID, "user-name")
|
|
|
+ password = driver.find_element(By.ID, "password")
|
|
|
+ login = driver.find_element(By.ID, "login-button")
|
|
|
+
|
|
|
+ writeInInput(inputElement=username, text="standard_user")
|
|
|
+ writeInInput(password, text="secret_sauce")
|
|
|
+ login.click()
|
|
|
+
|
|
|
+ assert (
|
|
|
+ driver.current_url == "https://www.saucedemo.com/inventory.html"
|
|
|
+ ), "Nous ne somme pas sur la bonne page"
|
|
|
+
|
|
|
+ #ajout "Sauce Labs Bike Light" au panier -- A changer si Tiff implémente une fonction pour le faire
|
|
|
+ item_lamp = driver.find_element(By.ID, "add-to-cart-sauce-labs-bike-light")
|
|
|
+ item_lamp.click()
|
|
|
+
|
|
|
+ #affichage panier -- A changer si Tiff implémente une fonction pour le faire
|
|
|
+ panier_btn= driver.find_element(By.ID, "shopping_cart_container")
|
|
|
+ panier_btn.click()
|
|
|
+
|
|
|
+ #redirection vers la pade de checkout
|
|
|
+ #go_to_checkout() -- A DEBUGG
|
|
|
+
|
|
|
+ checkout_btn = driver.find_element(By.CSS_SELECTOR, "#checkout")
|
|
|
+ checkout_btn.click()
|
|
|
+
|
|
|
+ assert (
|
|
|
+ driver.current_url == "https://www.saucedemo.com/checkout-step-one.html"
|
|
|
+ ), "Nous ne somme pas sur la bonne page"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ driver.quit()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+##### TIFF
|