Browse Source

Selenium commit

Abbas AHMAD 1 year ago
parent
commit
091675d549
2 changed files with 42 additions and 0 deletions
  1. 8 0
      test_math.py
  2. 34 0
      test_saucedemo.py

+ 8 - 0
test_math.py

@@ -1,6 +1,8 @@
 import math
 import logging
+import pytest
 
+@pytest.mark.skip
 def test_logging():
    logging.basicConfig(level=logging.DEBUG)
    logging.debug("Debug")
@@ -9,26 +11,32 @@ def test_logging():
    logging.error("Message Error")
    logging.critical("Message Critical")
 
+@pytest.mark.skip
 def test_sqrt():
    num = 25
    assert math.sqrt(num) == 5
 
+@pytest.mark.skip
 def testsquare():
    num = 7
    assert 7*7 == 49
 
+@pytest.mark.skip
 def test_greater():
    num = 101
    assert num > 100
 
+@pytest.mark.skip
 def test_greater_equal():
    num = 100
    assert num >= 100
 
+@pytest.mark.skip
 def test_less():
    num = 100
    assert num < 200
 
+@pytest.mark.skip
 def test_equal():
    logging.info("Test Equal")
    num = 100

+ 34 - 0
test_saucedemo.py

@@ -0,0 +1,34 @@
+import logging as log
+import pytest
+from selenium import webdriver
+from selenium.webdriver.common.by import By
+from selenium.webdriver.firefox.options import Options
+
+
+def writeInInput(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 test_loginOK():
+    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/")
+    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"
+
+    driver.quit()
+