|
@@ -178,4 +178,58 @@ def test_ajout_panier():
|
|
|
button_panier.click()
|
|
|
|
|
|
slip(2)
|
|
|
- driver.quit()
|
|
|
+ driver.quit()
|
|
|
+
|
|
|
+def test_detail_article():
|
|
|
+
|
|
|
+ #options = webdriver.FirefoxOptions()
|
|
|
+ #options.add_argument('--headless')
|
|
|
+
|
|
|
+ #driver = webdriver.Firefox(options=options)
|
|
|
+
|
|
|
+ driver=webdriver.Chrome()
|
|
|
+ url_sauce_demo="https://www.saucedemo.com/"
|
|
|
+
|
|
|
+
|
|
|
+ #Navigation sur le site:
|
|
|
+ driver.get(url_sauce_demo)
|
|
|
+ #Se logger:
|
|
|
+ champ_username = driver.find_element(By.XPATH,'//*[@id="user-name"]')
|
|
|
+
|
|
|
+ log.info(champ_username)
|
|
|
+ champ_username.send_keys("standard_user")
|
|
|
+ log.info("texte du champ username"+champ_username.text)
|
|
|
+ log.info("L'attribut du champ username est "+ champ_username.get_attribute("placeholder") )
|
|
|
+ assert champ_username.get_attribute("value")=="standard_user"
|
|
|
+
|
|
|
+ champ_mdp = driver.find_element(By.CSS_SELECTOR,'#password')
|
|
|
+ champ_mdp.send_keys("secret_sauce")
|
|
|
+ #champ_mdp.send_keys(Keys.RETURN)
|
|
|
+ button_login = driver.find_element(By.ID,"login-button")
|
|
|
+ element_visible_actif(button_login)
|
|
|
+ button_login.click()
|
|
|
+ assert driver.current_url=="https://www.saucedemo.com/inventory.html", "l'url de la page ouverte ("+ driver.current_url + ") n'est pas égal à https://www.saucedemo.com/inventory.html"
|
|
|
+
|
|
|
+ button_add=driver.find_element(By.XPATH,'//*[@id="add-to-cart-sauce-labs-bolt-t-shirt"]')
|
|
|
+ button_add.click()
|
|
|
+ button_panier=driver.find_element(By.CLASS_NAME,"shopping_cart_link")
|
|
|
+ button_panier.click()
|
|
|
+
|
|
|
+ # vérifier si le panier s'ouvre
|
|
|
+ if "cart" in driver.current_url:
|
|
|
+ print("Cart button functionality is working.")
|
|
|
+ else:
|
|
|
+ print("There was an issue with the cart button.")
|
|
|
+
|
|
|
+ # Vérifier si on a le bon article dans le panier
|
|
|
+ correct_item_name = "Sauce Labs Bolt T-shirt"
|
|
|
+ item_in_cart = driver.find_element(By.XPATH, f"//div[@class='inventory_item_name']")
|
|
|
+
|
|
|
+ if item_in_cart:
|
|
|
+ print(f"The correct item '{correct_item_name}' is in the cart.")
|
|
|
+ else:
|
|
|
+ print(f"The correct item '{correct_item_name}' is NOT in the cart.")
|
|
|
+
|
|
|
+
|
|
|
+ slip(2)
|
|
|
+ driver.quit()
|