-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
93 lines (65 loc) · 2.69 KB
/
Copy pathtests.py
File metadata and controls
93 lines (65 loc) · 2.69 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import unittest
from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import random
import json
import time
import os
from selenium.webdriver.support import expected_conditions as EC
class wait_for_loading(object):
def __init__(self, locator):
self.locator = locator
def __call__(self, driver):
try:
print("xxxxxx")
print(driver)
print(self.locator)
element = EC._find_element(driver, self.locator)
return False if "loading" in element.get_attribute("class") else True
except:
return False
driver = webdriver.Chrome()
class MyTest(unittest.TestCase):
def setUp(self):
driver.get("http://localhost:8800/")
@unittest.skip("not now")
def test_signup(self):
signup_btn = driver.find_element_by_class_name("signup-btn")
signup_btn.click()
usernameInput = driver.find_element_by_id("username")
usernameInput.send_keys("Moustafa")
emailInput = driver.find_element_by_id("email")
emailInput.send_keys("Moustafa@gmail.com")
passwordInput = driver.find_element_by_id("password")
passwordInput.send_keys("111111")
retype_passwordInput = driver.find_element_by_id("retype_password")
retype_passwordInput.send_keys("111111")
retype_passwordInput.send_keys(Keys.RETURN)
self.assertEqual(driver.current_url, "http://localhost:8800/")
def test_signin(self):
signup_btn = driver.find_element_by_class_name("signin-btn")
signup_btn.click()
usernameInput = driver.find_element_by_id("username")
usernameInput.send_keys("Moustafa")
passwordInput = driver.find_element_by_id("password")
passwordInput.send_keys("111111")
passwordInput.send_keys(Keys.RETURN)
self.assertEqual(driver.current_url, "http://localhost:8800/")
driver.find_element_by_class_name("header-logo").click()
def test_follow(self):
for btn in driver.find_elements_by_class_name("toggle-follow"):
btn.click()
#driver.find_element_by_class_name("header-logo").click()
for rating in driver.find_elements_by_class_name("rating"):
rating.find_element_by_xpath(".//i[3]").click()
self.assertEqual(driver.current_url, "http://locfalhost:8800/")
@classmethod
def tearDownClass(cls):
# driver.quit()
pass
unittest.main()