forked from IQSS/dataverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_create_test_account.py
74 lines (68 loc) · 3.61 KB
/
test_create_test_account.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
72
73
74
from selenium import webdriver
import time, unittest, config
def is_alert_present(wd):
try:
wd.switch_to_alert().text
return True
except:
return False
class test_create_test_account(unittest.TestCase):
def setUp(self):
if (config.local):
self.wd = webdriver.Firefox()
else:
desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
desired_capabilities['version'] = '24'
desired_capabilities['platform'] = 'Linux'
desired_capabilities['name'] = 'test_access'
self.wd = webdriver.Remote(
desired_capabilities=desired_capabilities,
command_executor="http://esodvn:[email protected]:80/wd/hub"
)
self.wd.implicitly_wait(60)
def test_test_create_test_account(self):
success = True
wd = self.wd
wd.get(config.accessURL)
wd.find_element_by_link_text("Create Account").click()
wd.find_element_by_id("dataverseUserForm:userName").click()
wd.find_element_by_id("dataverseUserForm:userName").clear()
wd.find_element_by_id("dataverseUserForm:userName").send_keys("tester")
wd.find_element_by_id("dataverseUserForm:inputPassword").click()
wd.find_element_by_id("dataverseUserForm:inputPassword").clear()
wd.find_element_by_id("dataverseUserForm:inputPassword").send_keys("tester")
wd.find_element_by_id("dataverseUserForm:retypePassword").click()
wd.find_element_by_id("dataverseUserForm:retypePassword").clear()
wd.find_element_by_id("dataverseUserForm:retypePassword").send_keys("tester")
wd.find_element_by_id("dataverseUserForm:firstName").click()
wd.find_element_by_id("dataverseUserForm:firstName").clear()
wd.find_element_by_id("dataverseUserForm:firstName").send_keys("test")
wd.find_element_by_id("dataverseUserForm:lastName").click()
wd.find_element_by_id("dataverseUserForm:lastName").clear()
wd.find_element_by_id("dataverseUserForm:lastName").send_keys("user")
wd.find_element_by_id("dataverseUserForm:email").click()
wd.find_element_by_id("dataverseUserForm:email").clear()
wd.find_element_by_id("dataverseUserForm:email").send_keys("[email protected]")
wd.find_element_by_id("dataverseUserForm:institution").click()
wd.find_element_by_id("dataverseUserForm:institution").clear()
wd.find_element_by_id("dataverseUserForm:institution").send_keys("IQSS")
wd.find_element_by_xpath("//div[@id='dataverseUserForm:j_idt45']/div[3]").click()
wd.find_element_by_xpath("//div[@class='ui-selectonemenu-items-wrapper']//li[.='Staff']").click()
wd.find_element_by_id("dataverseUserForm:phone").click()
wd.find_element_by_id("dataverseUserForm:phone").clear()
wd.find_element_by_id("dataverseUserForm:phone").send_keys("1-222-333-4444")
wd.find_element_by_id("dataverseUserForm:save").click()
time.sleep(1)
if ("This Username is already taken." in wd.find_element_by_tag_name("html").text):
print("Username exists. Exiting.")
return
if not ("Log Out" in wd.find_element_by_tag_name("html").text):
success = false
print("User was not logged in after create account.")
self.assertTrue(success)
def tearDown(self):
if not (config.local):
print("Link to your job: https://saucelabs.com/jobs/%s" % self.wd.session_id)
self.wd.quit()
if __name__ == '__main__':
unittest.main()