-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_e2e.py
71 lines (58 loc) · 2.37 KB
/
test_e2e.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Generated by Selenium IDE
"""
Test execution command:
python -m pytest -v
"""
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
BASE_URL = "http://localhost:30030"
CORRECT_USER = {"email": "[email protected]", "password": "1234"}
WRONG_USER = {"email": "[email protected]", "password": "wrong"}
class BaseTestClass:
def setup_method(self, method):
options = webdriver.ChromeOptions()
options.add_argument("-headless=new")
self.driver = webdriver.Chrome(options=options)
self.wait = WebDriverWait(self.driver, timeout=2)
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def login(self, user):
self.driver.get(BASE_URL + "/")
self.driver.find_element(By.LINK_TEXT, "무료로 시작하기").click()
self.driver.find_element(By.ID, "email").click()
self.driver.find_element(By.ID, "email").send_keys(user["email"])
self.driver.find_element(By.ID, "password").click()
self.driver.find_element(By.ID, "password").send_keys(user["password"])
self.driver.find_element(By.XPATH, "//button[contains(.,'로그인')]").click()
def logout(self):
self.driver.find_element(By.XPATH, "//p[contains(.,'로그아웃')]").click()
class TestLoginLogout(BaseTestClass):
def test_login_fail(self):
self.login(WRONG_USER)
alert = self.wait.until(expected_conditions.alert_is_present())
assert alert.text == "로그인에 실패했습니다."
def test_login_logout(self):
self.login(CORRECT_USER)
self.driver.implicitly_wait(2)
self.logout()
class TestNotesView(BaseTestClass):
def test_notes_view(self):
self.login(CORRECT_USER)
self.driver.implicitly_wait(2)
assert (
self.driver.find_element(
By.CSS_SELECTOR, "#root > div > div.side-bar > div.user > p"
).text
== "[email protected]"
)
self.driver.find_element(By.XPATH, "//a[last()]/p").click()
self.logout()