-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource.py
54 lines (45 loc) · 2.43 KB
/
source.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.common.action_chains import ActionChains
from constants import globalConstants
class Test_Sauce:
def __init__(self):
self.driver = webdriver.Safari()
self.driver.maximize_window()
self.driver.get("https://www.saucedemo.com")
def test_invalid_login(self):
# en fazla 5 saniye olacak şekilde user-name id'li elementin görünmesini bekle
WebDriverWait(self.driver,5).until(ec.visibility_of_element_located((By.ID,"user-name")))
usernameInput = self.driver.find_element(By.ID, "user-name")
WebDriverWait(self.driver,5).until(ec.visibility_of_element_located((By.ID,"password")))
passwordInput = self.driver.find_element(By.ID,"password")
usernameInput.send_keys("1")
passwordInput.send_keys("1")
loginBtn = self.driver.find_element(By.ID,"login-button")
loginBtn.click()
errorMessage = self.driver.find_element(By.XPATH,"//*[@id='login_button_container']/div/form/div[3]/h3")
errorMessage.text == "Epic sadface: Username and password do not match any user in this service"
print(f"TEST SONUCU: {errorMessage.text}")
def test_valid_login(self):
# self.driver.get(globalConstants.URL)
self.driver.get("https://www.saucedemo.com")#üst üste yazıyı engellemk için
WebDriverWait(self.driver,5).until(ec.visibility_of_element_located((By.ID,"user-name")))
usernameInput = self.driver.find_element(By.ID, "user-name")
WebDriverWait(self.driver,5).until(ec.visibility_of_element_located((By.ID,"password")))
passwordInput = self.driver.find_element(By.ID,"password")
# Action Chains
actions = ActionChains(self.driver)
actions.send_keys_to_element(usernameInput, "standard_user")
actions.send_keys_to_element(passwordInput,"secret_sauce")
actions.perform()
#usernameInput.send_keys("standard_user")
#passwordInput.send_keys("secret_sauce")
loginBtn = self.driver.find_element(By.ID,"login-button")
loginBtn.click()
self.driver.execute_script("window.scrollTo(0,500)")
testClass = Test_Sauce()
testClass.test_invalid_login()
testClass.test_valid_login()