123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- ##### 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
- import os
- class TestSauceDemo():
- def is_windows(self):
- #oups
- res = False
- if os.name == 'nt':
- res == True
- return res
-
- def writeInInput(self, inputElement, text):
- assert inputElement.is_displayed(), "Le champ texte n'est pas affiché"
- assert inputElement.is_enabled(), "Le champ texte n'est pas activé"
- inputElement.clear()
- inputElement.send_keys(text)
- def setup_method(self, method):
- log.info("Methode de SETUP AVANT CHAQUE TEST")
- if self.is_windows():
- self.driver = webdriver.Firefox()
- else:
- options = webdriver.FirefoxOptions()
- options.add_argument("--headless")
- self.driver = webdriver.Firefox(options=options)
- self.driver.get("http://www.saucedemo.com")
- assert (self.driver.current_url == "https://www.saucedemo.com/"), "Nous ne somme pas sur la bonne page"
- def teardown_method(self, method):
- log.info("Methode de TEARDOWN APRES CHAQUE TEST")
- self.driver.quit()
- def login(self):
- username = self.driver.find_element(By.ID, "user-name")
- password = self.driver.find_element(By.ID, "password")
- login = self.driver.find_element(By.ID, "login-button")
- writeInInput(inputElement=username, text="standard_user")
- writeInInput(password, text="secret_sauce")
- login.click()
- def logout(self):
- burger = self.driver.find_element(By.ID, "react-burger-menu-btn")
- burger.click()
- logout = self.driver.find_element(By.ID, "logout_sidebar_link")
- logout.click()
- @pytest.mark.skip("")
- def test_saucedemo_boutenbout(self):
- self.login()
- self.logout()
- ##### MANEL
-
-
- ##### MATTHIEU
-
- def go_to_checkout(self):
- checkout = self.driver.find_element(By.CSS_SELECTOR, "#checkout")
- checkout.click()
- #@pytest.mark.skip("")
- def test_affichage_Checkout(self):
- log.info("Test de la redirection sur la page de Checkout")
- #connexion Swag Labs
- self.login()
-
- #ajout "Sauce Labs Bike Light" au panier -- A changer si Tiff implémente une fonction pour le faire
- item_lamp = self.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= self.driver.find_element(By.ID, "shopping_cart_container")
- panier_btn.click()
- #redirection vers la page de checkout
- self.go_to_checkout()
-
- assert (
- self.driver.current_url == "https://www.saucedemo.com/checkout-step-one.html"
- ), "Nous ne somme pas sur la bonne page"
-
- ##### TIFF
-
|