-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserScenarioTests.py
105 lines (89 loc) · 3.97 KB
/
userScenarioTests.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException, NoAlertPresentException
from HomePanel import HomePanel
from LoginPanel import LoginPanel
from CatalogPanel import CatalogPanel
from AboutPanel import AboutPanel
from NewsPanel import NewsPanel
from DevelopersPanel import DevelopersPanel
import unittest, time, re
class userScenarioTests(unittest.TestCase):
"""Implementation of use case scenarios describe in the
Recast-database wiki as they apply to the web interface """
pageURL = "http://recast.perimeterinstitute.ca" # Change when final web URL exists
pageTitleLoggedin = "testuser1 | RECAST [beta]" # Change when non-Beta
pageTitleNoLogin = "Latest Requests | RECAST [beta]" # Change when non-Beta
testuser = "testuser1"
userpwd = "Pd6g%X2"
def setUp(self):
self.driver = webdriver.Firefox()
#self.driver = webdriver.Chrome() # Alternate driver if desired
self.driver.implicitly_wait(5)
def tearDown(self):
self.driver.close()
def listAllRqstForAnalysis(self):
'''Scenario: I want to be able to list all requests associated to a
given analysis'''
homepanel = HomePanel( self.driver, self.pageURL)
homepanel.get("/")
homepanel.analysesCatalog().click()
anacatpanel = homepanel.getAnaCatalog().get('/')
def listModelParamsForRequest(self):
'''Scenario: I want to be able to list all model parameters and their
values for a given request'''
homepanel = HomePanel(self.driver,self.pageURL)
homepanel.get("/")
loginpanel = homepanel.getLoginPanel()
loginpanel.username = self.testuser
loginpanel.password = self.userpwd
loginpanel.loginsubmit.click()
homepanel = loginpanel.homeLink.click()
homepanel.catalogLink().click()
anacatpanel = homepanel.getAnaCatalog().get('/')
anacatpanel.get("/")
def viewMyAnalyses(self):
'''Scenario: I want to be able to view all analyses I have submitted'''
homepanel = HomePanel(self.driver,self.pageURL)
homepanel.get("/")
loginpanel = homepanel.getLoginPanel()
loginpanel.username = self.testuser
loginpanel.password = self.userpwd
loginpanel.loginsubmit.click()
def viewAllAnalyses(self):
'''Scenario: I want to be able to view all analyses submitted by others'''
homepanel = HomePanel(self.driver,self.pageURL)
homepanel.get("/")
def viewDescAndArticlesForAnalysis(self):
'''Scenario: I want to be able to view a description and published
articles associated with an analysis'''
homepanel = HomePanel(self.driver,self.pageURL)
homepanel.get("/")
def viewModelDescription(self):
'''Scenario: I want to be able to view a description of a given model'''
homepanel = HomePanel(self.driver,self.pageURL)
homepanel.get("/")
## BOILERPLATE FUNCTIONS PROVIDED BY SELENIUM IDE CAPTURES
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException, e: return False
return True
def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException, e: return False
return True
def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
#alert = self.webdriver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True
#---START OF SCRIPT
if __name__=="__main__":
suite = unittest.TestLoader().loadTestsFromTestCase (userScenarioTests)
unittest.TextTestRunner(verbosity=2).run(suite)