|
@@ -15,18 +15,9 @@ import os
|
|
|
|
|
|
|
|
|
|
class TestSauceDemo:
|
|
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)
|
|
|
|
|
|
+##### METHODES PYTEST
|
|
|
|
+
|
|
|
|
|
|
def setup_method(self, method):
|
|
def setup_method(self, method):
|
|
log.info("Methode de SETUP AVANT CHAQUE TEST")
|
|
log.info("Methode de SETUP AVANT CHAQUE TEST")
|
|
@@ -47,6 +38,22 @@ class TestSauceDemo:
|
|
log.info("Methode de TEARDOWN APRES CHAQUE TEST")
|
|
log.info("Methode de TEARDOWN APRES CHAQUE TEST")
|
|
self.driver.quit()
|
|
self.driver.quit()
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+##### METHODES DIVERS
|
|
|
|
+ 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 login(self):
|
|
def login(self):
|
|
username = self.driver.find_element(By.ID, "user-name")
|
|
username = self.driver.find_element(By.ID, "user-name")
|
|
password = self.driver.find_element(By.ID, "password")
|
|
password = self.driver.find_element(By.ID, "password")
|
|
@@ -55,6 +62,15 @@ class TestSauceDemo:
|
|
writeInInput(inputElement=username, text="standard_user")
|
|
writeInInput(inputElement=username, text="standard_user")
|
|
writeInInput(password, text="secret_sauce")
|
|
writeInInput(password, text="secret_sauce")
|
|
login.click()
|
|
login.click()
|
|
|
|
+
|
|
|
|
+ def login_custum(self, user, pwd):
|
|
|
|
+ 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=user)
|
|
|
|
+ writeInInput(password, text=pwd)
|
|
|
|
+ login.click()
|
|
|
|
|
|
def logout(self):
|
|
def logout(self):
|
|
burger = self.driver.find_element(By.ID, "react-burger-menu-btn")
|
|
burger = self.driver.find_element(By.ID, "react-burger-menu-btn")
|
|
@@ -62,28 +78,28 @@ class TestSauceDemo:
|
|
logout = self.driver.find_element(By.ID, "logout_sidebar_link")
|
|
logout = self.driver.find_element(By.ID, "logout_sidebar_link")
|
|
logout.click()
|
|
logout.click()
|
|
|
|
|
|
- @pytest.mark.skip("")
|
|
|
|
- def test_saucedemo_boutenbout(self):
|
|
|
|
- self.login()
|
|
|
|
- self.logout()
|
|
|
|
|
|
+
|
|
|
|
|
|
def add_item(self, item):
|
|
def add_item(self, item):
|
|
self.driver.find_element(By.ID, f"add-to-cart-sauce-labs-{item}").click()
|
|
self.driver.find_element(By.ID, f"add-to-cart-sauce-labs-{item}").click()
|
|
return item
|
|
return item
|
|
|
|
|
|
- ##### MATTHIEU
|
|
|
|
|
|
+ def go_to_checkout(self):
|
|
|
|
+ checkout = self.driver.find_element(By.CSS_SELECTOR, "#checkout")
|
|
|
|
+ checkout.click()
|
|
|
|
|
|
- ##### MANEL
|
|
|
|
|
|
+ ##### TEST ABBAS
|
|
|
|
+
|
|
|
|
+ @pytest.mark.skip("")
|
|
|
|
+ def test_saucedemo_boutenbout(self):
|
|
|
|
+ self.login()
|
|
|
|
+ self.logout()
|
|
|
|
+
|
|
|
|
+ ##### TEST MANEL
|
|
|
|
|
|
- def login_custum(self, user, pwd):
|
|
|
|
- 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=user)
|
|
|
|
- writeInInput(password, text=pwd)
|
|
|
|
- login.click()
|
|
|
|
|
|
|
|
|
|
+ @pytest.mark.skip("")
|
|
def test_login_bad_username(self):
|
|
def test_login_bad_username(self):
|
|
self.login_custum("test", "secret_sauce")
|
|
self.login_custum("test", "secret_sauce")
|
|
|
|
|
|
@@ -95,6 +111,7 @@ class TestSauceDemo:
|
|
== "Epic sadface: Username and password do not match any user in this service"
|
|
== "Epic sadface: Username and password do not match any user in this service"
|
|
), "le message est erroné"
|
|
), "le message est erroné"
|
|
|
|
|
|
|
|
+ @pytest.mark.skip("")
|
|
def test_login_bad_passwrd(self):
|
|
def test_login_bad_passwrd(self):
|
|
self.login_custum("standard_user", "test")
|
|
self.login_custum("standard_user", "test")
|
|
|
|
|
|
@@ -106,13 +123,9 @@ class TestSauceDemo:
|
|
== "Epic sadface: Username and password do not match any user in this service"
|
|
== "Epic sadface: Username and password do not match any user in this service"
|
|
), "le message est erroné"
|
|
), "le message est erroné"
|
|
|
|
|
|
- ##### MATTHIEU
|
|
|
|
|
|
+ ##### TEST MATTHIEU
|
|
|
|
|
|
- def go_to_checkout(self):
|
|
|
|
- checkout = self.driver.find_element(By.CSS_SELECTOR, "#checkout")
|
|
|
|
- checkout.click()
|
|
|
|
-
|
|
|
|
- # @pytest.mark.skip("")
|
|
|
|
|
|
+ #@pytest.mark.skip("")
|
|
def test_affichage_Checkout(self):
|
|
def test_affichage_Checkout(self):
|
|
log.info("Test de la redirection sur la page de Checkout")
|
|
log.info("Test de la redirection sur la page de Checkout")
|
|
|
|
|
|
@@ -135,7 +148,9 @@ class TestSauceDemo:
|
|
== "https://www.saucedemo.com/checkout-step-one.html"
|
|
== "https://www.saucedemo.com/checkout-step-one.html"
|
|
), "Nous ne somme pas sur la bonne page"
|
|
), "Nous ne somme pas sur la bonne page"
|
|
|
|
|
|
- ##### TIFF
|
|
|
|
|
|
+ ##### TEST TIFF
|
|
|
|
+
|
|
|
|
+ @pytest.mark.skip("")
|
|
def test_add_item(self):
|
|
def test_add_item(self):
|
|
self.login()
|
|
self.login()
|
|
sauce_labs_item = self.add_item("backpack")
|
|
sauce_labs_item = self.add_item("backpack")
|