-
Notifications
You must be signed in to change notification settings - Fork 0
/
testDocStore.rb
86 lines (74 loc) · 2.13 KB
/
testDocStore.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
#! /usr/bin/ruby
require 'rspec'
require 'selenium-webdriver'
require 'optparse'
require 'date'
require 'csv'
#Closes browser at end of test
def teardown
@browser.quit
end
#Main function
def run
setup
yield
teardown
end
#Opens CODAP with document server, logged in as guest.
def test_document_server(url)
test_name = "Test Document Server Connection"
puts test_name
get_website(url)
login_as_guest_test
if @browser.find_element(:css=>'.focus') #Dismisses the splashscreen if present
@wait.until{@browser.find_element(:css=>'.focus')}.click
end
login_toolshelf_button_test
login_test
end
def create_new_doc_test
#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
#Clicks on the Login as Guest button in the Login dialog box
def login_as_guest_test
#Click on Login as Guest button
sleep(1) #Sleep to slow down when testing on Chrome
@login_guest_button = @wait.until{@browser.find_element(:css=> ".dg-loginguest-button")}
if @login_guest_button
puts "Found Login in as guest button"
@login_guest_button.click
else
puts "Login as guest button not found"
end
end
#Clicks on the Login button in the Login dialog box
def login_test
#Click on Login button
@login_button = @browser.find_element(:css=> ".dg-login-button")
if @login_button
puts "Found Login button"
@login_button.click
else
puts "Login button not found"
end
end
#Clicks on the Login as Guest button in the toolshelf
def login_toolshelf_button_test
#Click on Login as Guest button
@login_toolshelf_button = @wait.until{@browser.find_element(:css=> '.dg-toolshelflogin-button')}
if @login_toolshelf_button
puts "Found Login button on Toolshelf"
@login_toolshelf_button.click
puts "Just clicked the Login on Toolshelf button"
else
puts "Login button on Toolshelf not found"
end
end