-
Notifications
You must be signed in to change notification settings - Fork 0
/
testLoginInChrome.rb
191 lines (140 loc) · 4.88 KB
/
testLoginInChrome.rb
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
require 'rspec'
require 'selenium-webdriver'
def setup
@browser = Selenium::WebDriver.for :chrome
@wait= Selenium::WebDriver::Wait.new(:timeout=>30)
@browser.manage.window.maximize
end
def teardown
@browser.quit
end
def run
setup
yield
#teardown
end
def getURL(url)
@browser.get(url)
puts "Page title is #{@browser.title}"
#Checks if correct document is on screen
if @browser.title == "Untitled Document - CODAP"
puts "Got right document"
else
puts "Got wrong page"
end
end
def testStandAlone(url)
getURL(url)
@wait.until{@browser.find_element(:css=>'.focus')}.click
createNewDocTest
end
def testWithDataInteractive(url)
getURL(url)
@wait.until{@browser.find_element(:css=>'.focus')}.click
@wait.until {@browser.find_element(:css=> '.dg-graph-button')}.click
@wait.until {@browser.find_element(:css=> '.dg-tables-button')}.click
runPerformanceHarness
end
def testWithDocumentServer(url)
getURL(url)
loginAsGuestTest
@wait.until{@browser.find_element(:css=>'.focus')}.click
@wait.until {@browser.find_element(:css=> '.dg-graph-button')}.click
@wait.until {@browser.find_element(:css=> '.dg-tables-button')}.click
runPerformanceHarness
loginToolshelfButtonTest
loginTest
end
def createNewDocTest
#Send document name to text field
@wait.until {@browser.find_element(:css=>"input.field")}.send_keys "testDoc"
@browser.find_element(:css=>"[title='Create a new document with the specified title']").click
#Validate that the document is created
if @browser.title.include?("testDoc")
puts "Created new document"
else
puts "Did not create new document"
end
end
def loginAsGuestTest
#Click on Login as Guest button
sleep(1)
@loginGuestButton = @wait.until{@browser.find_element(:css=> ".dg-loginguest-button")}
if @loginGuestButton
puts "Found Login in as guest button"
@loginGuestButton.click
else
puts "Login as guest button not found"
end
end
def loginTest
#Click on Login button
#@loginButton = @browser.find_element(:xpath, "//label[contains(.,'Login')]")
@loginButton = @browser.find_element(:css=> ".dg-login-button")
puts @loginButton
if @loginButton
puts "Found Login button"
@loginButton.click
else
puts "Login button not found"
end
#<a class="sso-button" href="/users/auth/cc_portal_codap_portal">CODAP Portal</a> for docserver login page.
end
def loginToolshelfButtonTest
#Click on Login as Guest button
@loginToolshelfButton = @wait.until{@browser.find_element(:css=> '.dg-toolshelflogin-button')}
if @loginToolshelfButton
puts "Found Login button on Toolshelf"
@loginToolshelfButton.click
puts "Just clicked the Login on Toolshelf button"
# loginTest
else
puts "Login button on Toolshelf not found"
end
end
def runPerformanceHarness
counter=0
total_trials=3
frame = @browser.find_element(:css=> "iframe")
@browser.switch_to.frame(frame)
trials = @browser.find_element(:name=>'numTrials')
trials.clear
trials.send_keys('20')
while counter < total_trials do
counter=counter+1
run_button_enabled = @wait.until{@browser.find_element(:name=>'run')}
run_button_enabled.click if run_button_enabled.enabled?
timeElement = @browser.find_element(:id=>'time')
timeElement if timeElement.displayed?
}
puts "Time result is #{timeResult.text} ms"
[email protected]_element(:id=>'rate')
puts "Rate result is #{rateResult.text} cases/sec"
end
@browser.switch_to.default_content
end
=begin
run do
testStandAlone("http://codap.concord.org/releases/latest/static/dg/en/cert/index.html")
end
run do
testWithDataInteractive("localhost:4020/dg?di=http://concord-consortium.github.io/codap-data-interactives/PerformanceHarness/PerformanceHarness.html")
end
=end
run do
testWithDocumentServer("localhost:4020/dg?documentServer=http://document-store.herokuapp.com&di=http://concord-consortium.github.io/codap-data-interactives/PerformanceHarness/PerformanceHarness.html")
end
#@url = "http://codap.concord.org/releases/latest/static/dg/en/cert/index.html?documentServer=http://document-store.herokuapp.com/"
#@url="http://codap.concord.org/releases/latest/static/dg/en/cert/index.html?documentServer=http://document-store.herokuapp.com&di=http://concord-consortium.github.io/codap-data-interactives/PerformanceHarness/PerformanceHarness.html"
#@url = "http://codap.concord.org/releases/build_0292/static/dg/en/cert/index.html?di=http://concord-consortium.github.io/codap-data-interactives/PerformanceHarness/PerformanceHarness.html"
=begin
#Click on File icon
@browser.find_element(:xpath=> "//canvas[@alt='File']").click
if (@browser.find_element(:xpath=> "//span[contains(.,'Close Document...')]")).displayed?
puts "Found Close Document"
@browser.find_element(:xpath=> "//span[contains(.,'Close Document...')]").click
else
puts "Close Document not displayed"
end
=end