-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sites.py
37 lines (29 loc) · 1.38 KB
/
test_sites.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
import unittest
from selenium import webdriver
import time
class TestSites(unittest.TestCase):
def mFunc(self, link):
try:
browser = webdriver.Chrome()
browser.get(link)
first_name = browser.find_element_by_xpath('//div[@class="first_block"]/div/label[text()="First name*"]/following-sibling::input')
first_name.send_keys("Alex")
last_name = browser.find_element_by_xpath('//div[@class="first_block"]/div/label[text()="Last name*"]/following-sibling::input')
last_name.send_keys("Pav")
email = browser.find_element_by_xpath('//div[@class="first_block"]/div/label[text()="Email*"]/following-sibling::input')
email.send_keys("pukpukpuk@mail.ru")
button = browser.find_element_by_css_selector("button.btn")
button.click()
time.sleep(1)
welcome_text_elt = browser.find_element_by_tag_name('h1')
welcome_text = welcome_text_elt.text
self.assertEqual("Congratulations! You have successfully registered!", welcome_text)
finally:
time.sleep(10)
browser.quit()
def test_link_1(self):
self.mFunc("http://suninjuly.github.io/registration1.html")
def test_link_2(self):
self.mFunc("http://suninjuly.github.io/registration2.html")
if __name__ == "__main__":
unittest.main()