bimblis 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjlmZjVjOWRlZDU4YzcxOWM4YzlkOGIxNzI5MWRhOGU5OTkxOWQxMQ==
4
+ ZTFmZjk5MjI3NzM0NmM4ZjliNjdmNDdmZGRiOGU5ZDE1Y2E4N2Q0Zg==
5
5
  data.tar.gz: !binary |-
6
- OWM0NDNhYjc4NzVhMGQ2YjVmYjRjODVlZTdlNGI1ZjVjODUzMzMzNg==
6
+ ZTE4YTA0OTlkOGZkNzQ1ZTYwMWYzNGVmYjRhMjA3YWI0OWI2YTc4Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTVlODQ1ZTUzNzAwOTc0YjRmMGI2NTMzNGU2M2NiNTAyZGRlNDExODFmM2Fm
10
- MDQ5MzIxZDY4MTM0Mzk0MDk4ZjY5NDY1ZWE2NjljYzM1YWQ2YmRmYmU4ZWE1
11
- OWUyZWZlNjAwZDNlN2JmYzQwM2RmZDUxZDMwNjBkNjZjYmIxZWU=
9
+ NWU2MjVjYTIzYjkxN2NiODJlYmRlNzY5YjIxYjk4YTA3MjNmNTZiY2YwYjQ2
10
+ NzVlNWYwYWFjYmYyYTY3Zjg1MTgxMzE0ZWE4ZTE2NTQ0MzIzZjI0MTU1NGMy
11
+ NDk3OTg0NjFhZGU5YWJjMDc4YTllOTZjZjIwOTMxMTdlODBjN2M=
12
12
  data.tar.gz: !binary |-
13
- NWRiMWQ0OGE3MzAwNmRiYjVlOTI2ZjY5ZjlkNGI3MzAyOGZiMjQ0MzIxMjg4
14
- Njc0NGFlNTNjZTY1M2M0ZjgxOWU2YjgzMzk4MDAxNGIzYmVkZGE4M2IzZDMx
15
- ZTQ5MGRkYzk1MjFhY2JjNWMwNmU2ZmVhY2Y0MmY3OTljZGZlMDI=
13
+ YzliMTViZWRkZTRlNzllZGZjMDk0MGU3NWNiOThlY2ExMzk1Y2U3OWUxYjJi
14
+ MTYxMWQwNDM5OTgyZWRhOTRkNWNlYjI2YWQ2NDM5NTMxYTZlODRiZjQ0ZTIz
15
+ NjllNWVjYjM4YjlkNDM5ZjgxNDM0ODZiNTdhOTFhNjllMDNjNWY=
@@ -0,0 +1,258 @@
1
+ # encoding : utf-8
2
+
3
+ module BasicMethods
4
+
5
+ include PageObject
6
+ include PageObject::PageFactory
7
+
8
+ #
9
+ # METHODS SECTION
10
+ #
11
+
12
+ def refresh_until_element_present (times, seconds, element)
13
+ element = element.downcase.gsub(' ', '_')
14
+ exists = send("#{element}?")
15
+ visible = send("#{element}_element")
16
+ times.to_i.times do |count|
17
+ if exists && visible.visible?
18
+ return true
19
+ else
20
+ sleep seconds.to_i
21
+ $browser.refresh
22
+ end
23
+ end
24
+ end
25
+
26
+ def refresh_until_element_not_present (times, seconds, element)
27
+ element = element.downcase.gsub(' ', '_')
28
+ exists = send("#{element}?")
29
+ visible = send("#{element}_element")
30
+ times.to_i.times do |count|
31
+ if exists && visible.visible?
32
+ sleep seconds.to_i
33
+ $browser.refresh
34
+ else
35
+ return true
36
+ end
37
+ end
38
+ end
39
+
40
+ def check_actual_url (url)
41
+ unless $browser.url.include? eval(url)
42
+ p $browser.url
43
+ p eval(url)
44
+ raise 'Incorrect URL!'
45
+ end
46
+ end
47
+
48
+ def browser_alert (option)
49
+ option = option.downcase
50
+ case option
51
+ when 'ok'
52
+ $browser.alert.ok
53
+ when 'cancel'
54
+ $browser.alert.close
55
+ else
56
+ raise 'no valid option selected'
57
+ end
58
+ end
59
+
60
+ #work in progress
61
+ # def click_all_links(element)
62
+ # element = element.downcase.gsub(' ', '_')
63
+ # wait_until{send("#{element}?")}
64
+ # select = send("#{element}_element")
65
+ #
66
+ # links_array = []
67
+ # $browser.links(xpath: ".//*[@title='Delete Ad']").take(total_results).each do |link|
68
+ # links_array << link.title
69
+ # end
70
+ # links_array.each do |link_number|
71
+ # $browser.link(:title, link_number).click
72
+ #
73
+ # wait_until{close_window_button?}
74
+ # close_window_button
75
+ # end
76
+ #
77
+ # if select.visible?
78
+ # select.click
79
+ # element = element.downcase.gsub(' ', '_')
80
+ # wait_until{send("#{element}?")}
81
+ # select = send("#{element}_element")
82
+ # end
83
+ # select = send("#{element}_element")
84
+ # end
85
+
86
+ def select_element (option, element)
87
+ element = element.downcase.gsub(' ', '_')
88
+ wait_until{send("#{element}_select?")}
89
+ object = send("#{element}_select_element")
90
+ wait_until{object.visible?}
91
+ wait_until{object.enabled?}
92
+ object.select(option)
93
+
94
+ $advanced_text_info[element] = option
95
+ end
96
+
97
+ def hover_element (element)
98
+ element = element.downcase.gsub(' ', '_')
99
+ wait_until{send("#{element}?")}
100
+
101
+ select = send("#{element}_element")
102
+ wait_until{select.visible?}
103
+
104
+ select.hover
105
+ end
106
+
107
+ def click_element (element)
108
+ element = element.downcase.gsub(' ', '_')
109
+ wait_until{send("#{element}?")}
110
+
111
+ select = send("#{element}_element")
112
+ wait_until{select.visible?}
113
+
114
+ select.click
115
+ end
116
+
117
+ def click_link (element)
118
+ element = element.downcase.gsub(' ', '_')
119
+ wait_until{send("#{element}_link?")}
120
+
121
+ select = send("#{element}_link_element")
122
+ wait_until{select.visible?}
123
+
124
+ send("#{element}_link")
125
+ end
126
+
127
+ def check_checkbox (check, element)
128
+ element = element.downcase.gsub(' ', '_')
129
+ wait_until{send("#{element}_checkbox?")}
130
+
131
+ select = send("#{element}_checkbox_element")
132
+ wait_until{select.visible?}
133
+
134
+ if check.downcase == 'check'
135
+ send("check_#{element}_checkbox")
136
+ elsif check.downcase == 'uncheck'
137
+ send("uncheck_#{element}_checkbox")
138
+ else
139
+ raise 'check unselected!'
140
+ end
141
+ end
142
+
143
+ def click_button(element)
144
+ element = element.downcase.gsub(' ', '_')
145
+ wait_until{send("#{element}_button?")}
146
+
147
+ button = send("#{element}_button_element")
148
+ wait_until{button.enabled?}
149
+ wait_until{button.visible?}
150
+
151
+ send("#{element}_button")
152
+ end
153
+
154
+ def check_exist_element(element)
155
+ element = element.downcase.gsub(' ', '_')
156
+ unless wait_until{send("#{element}?")}
157
+ raise "#{element} was not found!"
158
+ end
159
+ end
160
+
161
+ def check_element_not_exist(element)
162
+ element = element.downcase.gsub(' ', '_')
163
+ exists = send("#{element}?")
164
+ if exists
165
+ raise "#{element} was found!"
166
+ end
167
+ end
168
+
169
+ def record_element_text(element)
170
+ select = send("#{element}_element")
171
+ $advanced_text_info[element] = select.text
172
+ end
173
+
174
+ def input_text_field (element, faker = 'lorem paragraph')
175
+ element = element.downcase.gsub(' ', '_')
176
+
177
+ case faker.downcase
178
+ when 'lorem paragraph'
179
+ sample_text = Faker::Lorem.paragraph
180
+ when 'lorem name'
181
+ sample_text = Faker::Name.name
182
+ when 'lorem street'
183
+ sample_text = Faker::Address.street_address
184
+ when 'lorem zip'
185
+ sample_text = Faker::Address.zip_code
186
+ when 'lorem phone'
187
+ sample_text = Faker::PhoneNumber.phone_number
188
+ when 'lorem email'
189
+ sample_text = Faker::Internet.email
190
+ when 'lorem url'
191
+ sample_text = Faker::Internet.url
192
+ else
193
+ if $advanced_text_info[faker] != nil
194
+ sample_text = $advanced_text_info[faker]
195
+ else
196
+ sample_text = faker.to_s
197
+ end
198
+ end
199
+ $text_info.push(sample_text)
200
+ $advanced_text_info[element] = sample_text
201
+
202
+ wait_until{send("#{element}_field?")}
203
+
204
+ select = send("#{element}_field_element")
205
+ wait_until{select.visible?}
206
+
207
+ send("#{element}_field=", sample_text)
208
+ end
209
+
210
+ def check_element_content(element)
211
+ element = element.downcase.gsub(' ', '_')
212
+ wait_until{send("#{element}?")}
213
+ value = "false"
214
+ select = send("#{element}")
215
+
216
+ $text_info.each { |x|
217
+ if select.downcase.include? x.downcase
218
+ value = "true"
219
+ end
220
+ }
221
+ unless value == "true"
222
+ p select.downcase
223
+ p $text_info
224
+ raise 'Not found'
225
+ end
226
+ end
227
+
228
+ def check_element_not_contains(element)
229
+ element = element.downcase.gsub(' ', '_')
230
+ wait_until{send("#{element}?")}
231
+ value = "false"
232
+ select = send("#{element}")
233
+
234
+ $text_info.each { |x|
235
+ if select.downcase.include? x.downcase
236
+ value = "true"
237
+ end
238
+ }
239
+ unless value == "false"
240
+ raise 'Found!'
241
+ end
242
+ end
243
+
244
+ def adv_check_element_contains(element_objective, element_memory)
245
+ element_objective = element_objective.downcase.gsub(' ', '_')
246
+ element_memory = element_memory.downcase.gsub(' ', '_')
247
+ wait_until{send("#{element_objective}?")}
248
+ value = "false"
249
+ select_primary = send("#{element_objective}")
250
+ if select_primary.downcase.include? $advanced_text_info[element_memory].downcase
251
+ value = "true"
252
+ end
253
+
254
+ unless value == "true"
255
+ raise 'Not found'
256
+ end
257
+ end
258
+ end
@@ -0,0 +1,86 @@
1
+ Then (/In (.*?), I click all the elements of "(.*?)"$/) do |page, element|
2
+ on_page(page + 'Page').click_all_links(element)
3
+ end
4
+
5
+ Then (/In (.*?), I check element "(.*?)" contains the info of element "(.*?)"$/) do |page, element_objective, element_memory|
6
+ on_page(page + 'Page').adv_check_element_contains(element_objective, element_memory)
7
+ end
8
+
9
+ Then (/In (.*?), I hover over "(.*?)" and click in "(.*?)"$/) do |page, element1, element2|
10
+ on_page(page + 'Page').hover_element(element1)
11
+ on_page(page + 'Page').click_element(element2)
12
+ end
13
+
14
+ Then (/In (.*?), I click the element of "(.*?)"$/) do |page, element|
15
+ on_page(page + 'Page').click_element(element)
16
+ end
17
+
18
+ Then (/In (.*?), I hover the mouse over "(.*?)"$/) do |page, element|
19
+ on_page(page + 'Page').hover_element(element)
20
+ end
21
+
22
+ Then (/In (.*?), I randomly select option in "(.*?)"$/) do |page, element|
23
+ on_page(page + 'Page').input_select_list(element)
24
+ end
25
+
26
+ Then (/In (.*?), I choose option (.*?) in the select "(.*?)"$/) do |page, option, element|
27
+ on_page(page + 'Page').select_element(option, element)
28
+ end
29
+
30
+ Then (/In (.*?), I click the link of "(.*?)"$/) do |page, element|
31
+ on_page(page + 'Page').click_link(element)
32
+ end
33
+
34
+ Given(/^In (.*?), I click the button of "(.*?)"$/) do |page, element|
35
+ on_page(page + 'Page').click_button(element)
36
+ end
37
+
38
+ Then (/In (.*?), I check the existence of element "(.*?)"$/) do |page, element|
39
+ on_page(page + 'Page').check_exist_element(element)
40
+ end
41
+
42
+ Then (/In (.*?), I check the NON existence of element "(.*?)"$/) do |page, element|
43
+ on_page(page + 'Page').check_element_not_exist(element)
44
+ end
45
+
46
+ Given(/^In (.*?), I fill (.*?) in field "(.*?)"$/) do |page, lorem, element|
47
+ on_page(page + 'Page').input_text_field(element, lorem)
48
+ end
49
+
50
+ Given(/^In (.*?), I check if the element "(.*?)" contains the correct data$/) do |page, element|
51
+ on_page(page + 'Page').check_element_content(element)
52
+ end
53
+
54
+ Given(/^In (.*?), I check if the element "(.*?)" NOT contains the erased data$/) do |page, element|
55
+ on_page(page + 'Page').check_element_not_contains(element)
56
+ end
57
+
58
+ Then (/In (.*?), I (.*?) the checkbox of "(.*?)"$/) do |page, check, element|
59
+ on_page(page + 'Page').check_checkbox(check, element)
60
+ end
61
+
62
+ Then (/I should be in webpage "(.*?)"$/) do |url|
63
+ web = '$' + url.downcase.gsub(' ', '_')
64
+ on_page(HomePage).check_actual_url(web)
65
+ end
66
+
67
+ And (/^I navigate to this (.*?)$/) do |web|
68
+ web = '$' + web.downcase.gsub(' ', '_')
69
+ @browser.goto eval(web)
70
+ end
71
+
72
+ Then (/I select browser alert "(.*?)"$/) do |option|
73
+ on_page(HomePage).browser_alert(option)
74
+ end
75
+
76
+ Then (/^In (.*?), I refresh the browser "(.*?)" times, every "(.*?)" seconds, until the element "(.*?)" is present$/) do |page, times, seconds, element|
77
+ on_page(page + 'Page').refresh_until_element_present(times, seconds, element)
78
+ end
79
+
80
+ Then (/^In (.*?), I refresh the browser "(.*?)" times, every "(.*?)" seconds, until the element "(.*?)" is NOT present$/) do |page, times, seconds, element|
81
+ on_page(page + 'Page').refresh_until_element_not_present(times, seconds, element)
82
+ end
83
+
84
+ Then (/In (.*?), I record the text of element "(.*?)"$/) do |page, element|
85
+ on_page(page + 'Page').record_element_text(element)
86
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bimblis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pabloFernandezGarcia
@@ -45,7 +45,9 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - lib/basic_methods.rb
48
49
  - lib/bimblis.rb
50
+ - lib/web_shared_steps.rb
49
51
  homepage: http://www.google.com
50
52
  licenses:
51
53
  - MIT