forked from burbon000/rainforest_livefyre_automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
like_test.rb
166 lines (125 loc) · 5.32 KB
/
like_test.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
#tester starts at
# https://lemonsarebetter.herokuapp.com/widget.php?network=rainforestqa.fyre.co&site=383920&articleId=ekrfjherf34823&appType=reviews&userId=user1_9080908090
test(id: 27781, title: "Like") do
# You can use any of the following variables in your code:
# - []
random_num = rand(100000000...999999999).to_s
username_a = 'rftester483'
password_a = ''
username_b = 'rftester927'
password_b = ''
base_url = "https://lemonsarebetter.herokuapp.com/widget.php?network=rainforest-lfep.fyre.co"\
"&site=382781&articleId=#{random_num}&jsVersion=1.1.10"
window = Capybara.current_session.driver.browser.manage.window
#window.maximize
visit base_url
step id: 1,
action: "Click on the 'Sign in' button/link.",
response: "Do you see a sign in option?" do
# *** START EDITING HERE ***
# action
page.find(:css, "a[role='button']", :text => 'Sign in').click
# response
popup = page.driver.browser.window_handles.last
page.driver.browser.switch_to.window(popup)
expect(page).to have_content('Sign In With Email')
page.save_screenshot('screenshot_step_1.png')
# *** STOP EDITING HERE ***
end
step id: 2,
action: "Enter username: '{{commenter_email_account.emaila}}'' and password: '{{commenter_email_account.passworda}}'"\
" and click the 'Sign In' button.",
response: "Do you see '{{commenter_email_account.usernamea}}'' in the top left?" do
# *** START EDITING HERE ***
# action
fill_in 'username', with: username_a
fill_in 'password', with: password_a
page.find(:css, "input[value='Sign In']").click
# reponse
main_window = page.driver.browser.window_handles.first
page.driver.browser.switch_to.window(main_window)
expect(page).to have_content(username_a)
page.save_screenshot('screenshot_step_2.png')
# *** STOP EDITING HERE ***
end
step id: 3,
action: "Click in the textbox, type or copy in 'test comment', then click on the 'Post comment' button.",
response: "Do you see the comment appear under the textbox?" do
# *** START EDITING HERE ***
comment = 'Test Comment'
# action
within_frame(find(:css, '[aria-label=editor]')) do
expect(page.find(:css, 'p')['text']).to eql(nil)
page.find(:css, "body[role='textbox']").click
page.find(:css, "body[role='textbox']").native.send_keys(comment)
end
page.find("div[role='button']", :text => 'Post comment').click
# response
within(:css, 'article', :match => :first) do
expect(page).to have_content(comment)
expect(page).to have_content(username_a)
end
page.save_screenshot('screenshot_step_3.png')
# *** STOP EDITING HERE ***
end
step id: 4,
action: "In the top left, hover over '{{commenter_email_account.usernamea}}' and click on 'Sign out'",
response: "Does the text 'Sign in' appear in the top left?" do
# *** START EDITING HERE ***
# action
page.find(:css, "a[role='button']", :text => username_a).hover
page.find(:css, "a[role='button']", :text => 'Sign out').click
# response
expect(page).to have_content('Sign in')
page.save_screenshot('screenshot_step_4.png')
# *** STOP EDITING HERE ***
end
step id: 5,
action: "Click on the 'Sign in' button/link.",
response: "Do you see a sign in option?" do
# *** START EDITING HERE ***
# action
page.find(:css, "a[role='button']", :text => 'Sign in').click
# response
popup = page.driver.browser.window_handles.last
page.driver.browser.switch_to.window(popup)
expect(page).to have_content('Sign In With Email')
page.save_screenshot('screenshot_step_5.png')
# *** STOP EDITING HERE ***
end
step id: 6,
action: "Enter username: '{{commenter_email_account.emailb}}'' and password: '{{commenter_email_account.passwordb}}' "\
"and click the 'Sign In' button.",
response: "Do you see '{{commenter_email_account.usernameb}}'' in the top left?" do
# *** START EDITING HERE ***
# action
fill_in 'username', with: username_b
fill_in 'password', with: password_b
page.find(:css, "input[value='Sign In']").click
# reponse
main_window = page.driver.browser.window_handles.first
page.driver.browser.switch_to.window(main_window)
expect(page).to have_content(username_b)
page.save_screenshot('screenshot_step_6.png')
# *** STOP EDITING HERE ***
end
step id: 7,
action: "Click the 'Like' text button to the right of the comment 'test comment'. Refresh the page.",
response: "Do you see the text 'Unlike' to the right of the comment 'test comment'?" do
# *** START EDITING HERE ***
# action
within(:css, 'article', :match => :first) do
page.find(:css, 'a', :text => 'Like').click
end
# reponse
within(:css, 'article', :match => :first) do
expect(page).to have_content('Unlike')
expect(page).to have_content(username_a)
end
page.save_screenshot('screenshot_step_7.png')
# *** STOP EDITING HERE ***
end
page.find(:css, "a[role='button']", :text => username_b).hover
page.find(:css, "a[role='button']", :text => 'Sign out').click
#sleep(10)
end