-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsign-up-so.py
69 lines (54 loc) · 2.43 KB
/
sign-up-so.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
"""
author: @endormi
Automated stack overflow # form testing and generate report
"""
from selenium import webdriver
import unittest
import HtmlTestRunner
import time
"""
Install browser driver:
https://selenium.dev/downloads/
"""
class login_form_test(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.browser = webdriver.Chrome(r'file/to/driver/if/needed/otherwise/remove/r')
cls.browser.maximize_window()
def test_#_so(self):
time.sleep(1)
self.browser.get('https://stackoverflow.com/')
self.browser.find_element_by_link_text('#').click()
self.browser.find_element_by_id('display-name').send_keys('username')
self.browser.find_element_by_id('email').send_keys('example@gmail.com')
self.browser.find_element_by_id('password').send_keys('password')
self.browser.find_element_by_id('opt-in').click()
time.sleep(1)
self.browser.find_element_by_id('submit-button').click()
def test_#_with_gmail_auth(self):
time.sleep(1)
self.browser.get('https://stackoverflow.com/')
self.browser.find_element_by_link_text('#').click()
self.browser.find_element_by_xpath('/html/body/div[4]/div[2]/div/div[2]/div[2]/button[1]').click()
time.sleep(2)
self.browser.find_element_by_xpath('//*[@id="identifierId"]').send_keys('username')
time.sleep(1)
self.browser.find_element_by_xpath('//*[@id="identifierNext"]/span/span').click()
time.sleep(1)
self.browser.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input').send_keys('password')
time.sleep(1)
self.browser.find_element_by_xpath('//*[@id="passwordNext"]/span/span').click()
def test_#_with_github_auth(self):
time.sleep(1)
self.browser.get('https://stackoverflow.com/')
self.browser.find_element_by_link_text('#').click()
self.browser.find_element_by_xpath('/html/body/div[4]/div[2]/div/div[2]/div[2]/button[2]').click()
self.browser.find_element_by_id('login_field').send_keys('username')
self.browser.find_element_by_id('password').send_keys('password')
self.browser.find_element_by_class_name('btn-block').click()
@classmethod
def tearDownClass(cls):
time.sleep(5)
cls.browser.close()
if __name__ == '__main__':
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='output/path'))