-
Notifications
You must be signed in to change notification settings - Fork 0
/
support-12_dates_gr_by_wk.rb
202 lines (166 loc) · 6.71 KB
/
support-12_dates_gr_by_wk.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#tester starts at
# "https://app.Klipfolio.com/login"
test(id: 92243, title: "Support.12 - dates grouped by week") do
# You can use any of the following variables in your code:
# - []
# Sauce Labs testing - change full configuration
sauce_username=''
sauce_access_key=''
sauce_browser_name='firefox'
sauce_browser_version='45'
sauce_os_platform='Windows 7'
sauce_job_name='klipfolio_support_12_dates'
Capybara.register_driver :sauce do |app|
@desired_cap = {
'platform': "#{sauce_os_platform}",
'browserName': "#{sauce_browser_name}",
'version': "#{sauce_browser_version}",
'name': "#{sauce_job_name}",
}
Capybara::Selenium::Driver.new(app,
:browser => :remote,
:url => "http://#{sauce_username}:#{sauce_access_key}@ondemand.saucelabs.com:80/wd/hub",
:desired_capabilities => @desired_cap
)
end
#Selenium testing - change browser
selenium_browser = :firefox
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => selenium_browser)
end
#used to keep track of scroll position when scrolling down
scroll_offset = 0
visit "https://app.Klipfolio.com/"
step id: 1,
action: "Enter your username(email address): '{{qualityassuranceTesters.user}}' and password: "\
"'{{qualityassuranceTesters.pass}}' and click on the Sign in button",
response: "After the sign in, does your account First name: {{qualityassuranceTesters.firstname}}"\
" show up at the top right corner of the page?" do
# *** START EDITING HERE ***
expect(page).to have_content('Klipfolio')
username = ''
password = ''
first_name = ''
# action
fill_in 'username', with: username
fill_in 'password', with: password
page.find(:css, '#login').click
# response
expect(page).to have_selector(:css, '.account-dropdown', :text => first_name)
expect(page).to have_content('My Dashboards')
#page.save_screenshot('screenshot_step_1.png')
# *** STOP EDITING HERE ***
end
step id: 2,
action: "Open the '{{klipfolioCustomVariables.dashboardName_support}}' dashboard by selecting its tab",
response: "Does the '{{klipfolioCustomVariables.dashboardName_support}}' dashboard open?" do
# *** START EDITING HERE ***
# action
# scroll to the right in the dashboard menu bar if needed
within(:css, '#dashboard-tabs-container') do
for i in 1..5 do
if page.has_selector?(:css, '.btn-scroll.right-scroll', wait: 3)
page.find(:css, '.btn-scroll.right-scroll').click
end
if page.has_selector?(:css, 'li', :text => 'Support Klips (Applied Actions)', wait: 3)
page.find(:css, 'li', :text => 'Support Klips (Applied Actions)').click
break
end
end
end
# response
expect(page).to have_selector(:css, ".dashboard-tab.active[title='Support Klips (Applied Actions)']", wait: 30)
expect(page).to have_content('Klip 12')
page.all(:css, 'td', :minimum => 6, wait: 5)
#page.save_screenshot('screenshot_step_2.png')
# *** STOP EDITING HERE ***
end
step id: 3,
action: "Scroll down the page and verify that visualization 'Klip 12' renders successfully.",
response: "Does 'Klip 12' render with 2 drop-down list (Country and Medium) and a Table with 2 columns (Dates and Sessions)?" do
# *** START EDITING HERE ***
# action
# scroll down the screen to bring Klip 12 into view
for i in 1..4 do
scroll_offset += 450
page.execute_script("window.scrollTo(0,#{scroll_offset})")
end
# response
within(:css, '.klip', :text => 'Klip 12') do
expect(page).to have_content('Country')
expect(page).to have_content('Medium')
expect(page).to have_content('Dates')
expect(page).to have_content('Sessions')
expect(page.all(:css, 'th', :count => 2, wait: 30).count).to eql(2)
end
#page.save_screenshot('screenshot_step_3.png')
# *** STOP EDITING HERE ***
end
step id: 4,
action: "Scroll down the rows in the Table and note the Dates displayed",
response: "Are the dates grouped by weeks? format = YYYY-## . ie 2000-12 is 12th week of year 2000" do
# *** START EDITING HERE ***
# action
# response
within(:css, '.klip', :text => 'Klip 12') do
date_elements = page.all(:css, 'td', :minimum => 6, wait: 5)
for i in 0...date_elements.length do
if i.even?
if date_elements[i].text != ""
date_split = date_elements[i].text.split('-')
year = date_split[0].to_i
expect(year >= 2000).to eql(true)
expect(year <= 2018).to eql(true)
week = date_split[1].to_i
expect(week > 0).to eql(true)
expect(week < 54).to eql(true)
end
end
end
end
#page.save_screenshot('screenshot_step_4.png')
# *** STOP EDITING HERE ***
end
step id: 5,
action: "Verify that the values for the Dates column are sorted in ascending order",
response: "Are the values in ascending order?" do
# *** START EDITING HERE ***
# action
#do nothing
# response
within(:css, '.klip', :text => 'Klip 12') do
date_elements = page.all(:css, 'td', :visible => false, :minimum => 2)
date_texts = []
for i in 0...date_elements.length do
if i.even?
date_texts.push(date_elements[i].text.delete('-'))
end
end
date_texts = date_texts.reject(&:empty?)
expect(date_texts == date_texts.sort).to eql(true)
end
#page.save_screenshot('screenshot_step_5.png')
# *** STOP EDITING HERE ***
end
step id: 6,
action: "On Klip 12, Change the Medium drop-down to 'Chat' THEN count how many rows of data are returned.",
response: "Are there only 3 rows of data in the Table? (2016-43, 2017-26, and 2017-28)" do
# *** START EDITING HERE ***
# action
within(:css, '.klip', :text => 'Klip 12') do
page.select 'Chat'
end
# response
expected_texts = ['2016-43', '2017-26', '2017-28']
within(:css, '.klip', :text => 'Klip 12') do
date_elements = page.all(:css, 'td', :visible => true, :maximum => 7)
for i in 0...date_elements.length do
if i.even? # data is in every other td row
expect(expected_texts.include? date_elements[i].text).to eql(true)
end
end
end
#page.save_screenshot('screenshot_step_5.png')
# *** STOP EDITING HERE ***
end
end