teber-library 0.1.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/README.md +8 -0
  4. data/exe/teber +5 -0
  5. data/lib/teber.rb +38 -2
  6. data/lib/teber/version.rb +1 -1
  7. data/sample/.DS_Store +0 -0
  8. data/sample/.gitignore +1 -0
  9. data/sample/CONTRIBUTING.md +93 -0
  10. data/sample/Gemfile +20 -0
  11. data/sample/Gemfile.lock +130 -0
  12. data/sample/LICENSE +674 -0
  13. data/sample/README.md +263 -0
  14. data/sample/_config.yml +1 -0
  15. data/sample/config/cucumber.yml +2 -0
  16. data/sample/features/.DS_Store +0 -0
  17. data/sample/features/feature/.gitkeep +0 -0
  18. data/sample/features/feature/googleSearch.feature +27 -0
  19. data/sample/features/feature/googleSearchParallel.feature +9 -0
  20. data/sample/features/global-data/.gitkeep +0 -0
  21. data/sample/features/global-data/global.yml +4 -0
  22. data/sample/features/libraries/.gitkeep +0 -0
  23. data/sample/features/libraries/Teber_Ruby_Black.png +0 -0
  24. data/sample/features/libraries/categories.json +31 -0
  25. data/sample/features/libraries/driver.rb +212 -0
  26. data/sample/features/libraries/locator.rb +146 -0
  27. data/sample/features/libraries/wait.rb +31 -0
  28. data/sample/features/locators/.gitkeep +0 -0
  29. data/sample/features/locators/googleSearch.rb +18 -0
  30. data/sample/features/pages/.gitkeep +0 -0
  31. data/sample/features/pages/googleSearch.rb +21 -0
  32. data/sample/features/step_definitions/.gitkeep +0 -0
  33. data/sample/features/step_definitions/googleSearch.rb +31 -0
  34. data/sample/features/support/env.rb +82 -0
  35. data/sample/features/test-data/.gitkeep +0 -0
  36. data/sample/features/test-data/googleSearch.yml +2 -0
  37. data/sample/features/test-data/googleSearchParallel.yml +2 -0
  38. data/teber-library.gemspec +12 -0
  39. metadata +202 -2
@@ -0,0 +1,146 @@
1
+ # module Libraries
2
+ # class Locator
3
+ # attr_accessor :how
4
+ # attr_accessor :what
5
+ # attr_accessor :options
6
+
7
+ # def initialize(
8
+ # how,
9
+ # what,
10
+ # options = {
11
+ # "hidden" => false,
12
+ # "ajax_load" => false,
13
+ # })
14
+ # @how = how
15
+ # @what = what
16
+ # @options = options
17
+ # end
18
+
19
+ # def self.mouse_over(element, driver = $focus_driver)
20
+ # driver.action.move_to(element).perform
21
+ # end
22
+
23
+ # def click(driver = $focus_driver)
24
+ # begin
25
+ # driver.find_element(self).click
26
+ # puts "Clicked - #{self.how} => #{self.what}"
27
+ # rescue Exception => e
28
+ # puts "Not clicked at - #{self.how} => #{self.what}"
29
+ # puts e.message
30
+ # end
31
+ # end
32
+
33
+ # def text(driver = $focus_driver)
34
+ # return driver.find_element(self).text
35
+ # end
36
+
37
+ # def texts(driver = $focus_driver)
38
+ # elements_text = []
39
+ # driver.find_elements(self).each do |element|
40
+ # elements_text.push(element.text)
41
+ # end
42
+ # return elements_text
43
+ # end
44
+
45
+ # def displayed?(driver = $focus_driver)
46
+ # driver.find_element(self).displayed?
47
+ # end
48
+
49
+ # def enabled?(driver = $focus_driver)
50
+ # driver.find_element(self).enabled?
51
+ # end
52
+
53
+ # def is_enabled_with_wait?(timeout = $conf["implicit_wait"], driver = $focus_driver)
54
+ # index = 0
55
+ # while driver.find_element(self).enabled? == false
56
+ # sleep 1
57
+ # break if index == timeout
58
+ # index += 1
59
+ # end
60
+ # end
61
+
62
+ # def selected?(driver = $focus_driver)
63
+ # driver.find_element(self).selected?
64
+ # end
65
+
66
+ # def is_present?(driver = $focus_driver)
67
+ # driver.driver.manage.timeouts.implicit_wait = 0
68
+ # begin
69
+ # return driver.driver.find_element(self.how, self.what).displayed?
70
+ # rescue Exception => e
71
+ # driver.driver.manage.timeouts.implicit_wait = $conf["implicit_wait"]
72
+ # return false
73
+ # ensure
74
+ # driver.driver.manage.timeouts.implicit_wait = $conf["implicit_wait"]
75
+ # end
76
+ # end
77
+
78
+ # def is_not_present?(driver = $focus_driver)
79
+ # return !is_present?(driver)
80
+ # end
81
+
82
+ # def is_present_with_wait?(timeout = $conf["implicit_wait"], driver = $focus_driver)
83
+ # Wait.wait_for_element(self, timeout, driver)
84
+ # is_present?(driver)
85
+ # end
86
+
87
+ # def is_not_present_with_wait?(timeout = $conf["implicit_wait"], driver = $focus_driver)
88
+ # Wait.wait_for_element_hide(self, timeout, driver)
89
+ # return !is_present?(driver)
90
+ # end
91
+
92
+ # def click_if_present(driver = $focus_driver)
93
+ # click(driver) if is_present?(driver)
94
+ # end
95
+
96
+ # def click_if_present_with_wait(timeout = $conf["implicit_wait"], driver = $focus_driver)
97
+ # click(driver) if is_present_with_wait?(timeout, driver)
98
+ # end
99
+
100
+ # def move_and_click(driver = $focus_driver)
101
+ # element = driver.find_element(self)
102
+ # driver.action.move_to(element).click.perform
103
+ # end
104
+
105
+ # def scroll_to_locator(driver = $focus_driver)
106
+ # $focus_driver.scroll_to_locator(self)
107
+ # end
108
+
109
+ # ################################
110
+ # # Check box methods
111
+ # ################################
112
+
113
+ # def is_checked?(driver = $focus_driver)
114
+ # self.attribute("checked") == "true"
115
+ # end
116
+
117
+ # def check(driver = $focus_driver)
118
+ # self.click unless self.is_checked?
119
+ # end
120
+
121
+ # def uncheck(driver = $focus_driver)
122
+ # self.click if self.is_checked?
123
+ # end
124
+
125
+ # ##############################
126
+ # # Text box methods
127
+ # ##############################
128
+
129
+ # def clear(driver = $focus_driver)
130
+ # driver.find_element(self).clear
131
+ # end
132
+
133
+ # def send_keys(*args)
134
+ # $focus_driver.find_element(self).send_keys(*args)
135
+ # end
136
+
137
+ # def clear_and_send_keys(*args)
138
+ # clear($focus_driver)
139
+ # send_keys(*args)
140
+ # end
141
+
142
+ # def get_value(driver = $focus_driver)
143
+ # driver.find_element(self).attribute("value")
144
+ # end
145
+ # end
146
+ # end
@@ -0,0 +1,31 @@
1
+ # module Libraries
2
+ # module Wait
3
+
4
+ # # avoid defining self in def self.some_method -> def some_method
5
+ # class << self
6
+
7
+ # def wait_for_element(locator, timeout=$conf["implicit_wait"], focus_driver = $focus_driver)
8
+ # index=0
9
+ # while locator.is_present?(focus_driver) == false
10
+ # sleep 1
11
+ # if index == timeout
12
+ # break
13
+ # end
14
+ # index+=1
15
+ # end
16
+ # end
17
+
18
+ # def wait_for_element_hide(locator, timeout=$conf["implicit_wait"], focus_driver = $focus_driver)
19
+ # index=0
20
+ # while locator.is_present?(focus_driver) == true
21
+ # sleep 1
22
+ # if index == timeout
23
+ # break
24
+ # end
25
+ # index+=1
26
+ # end
27
+ # end
28
+ # end
29
+ # end
30
+ # end
31
+
File without changes
@@ -0,0 +1,18 @@
1
+ module Locators
2
+ class GoogleSearch
3
+
4
+ attr_reader :SEARCH_BOX
5
+ attr_reader :SEARCH_BUTTON
6
+ attr_reader :AFTER_SEARCH_IMAGE
7
+
8
+ def initialize
9
+
10
+ @SEARCH_BOX = Locator.new(:name, "q")
11
+ @SEARCH_BUTTON = Locator.new(:css, "input[name='btnK']")
12
+ @AFTER_SEARCH_IMAGE = Locator.new(:css, "div.logo img[alt*='Google']")
13
+
14
+ end
15
+
16
+ end
17
+ end
18
+
File without changes
@@ -0,0 +1,21 @@
1
+ module Pages
2
+ class GoogleSearch < Locators::GoogleSearch
3
+
4
+ def initialize
5
+ super()
6
+ end
7
+
8
+ def enter_text_and_search(string)
9
+ @SEARCH_BOX.is_present_with_wait?
10
+ @SEARCH_BOX.clear_and_send_keys(string)
11
+ @SEARCH_BUTTON.scroll_to_locator
12
+ @SEARCH_BUTTON.move_and_click
13
+ end
14
+
15
+ def is_results_page_displayed?
16
+ @AFTER_SEARCH_IMAGE.is_present_with_wait?
17
+ end
18
+
19
+ end
20
+ end
21
+
File without changes
@@ -0,0 +1,31 @@
1
+ Before('@TC_Google_Search') do
2
+ $filter_run_once ||= false # have to define a variable before we can reference its value
3
+ if !$filter_run_once
4
+ @@google_page = Pages::GoogleSearch.new
5
+ end
6
+ $filter_run_once = true
7
+ end
8
+
9
+ Before('@TC_Google_Search') do
10
+ @@driver = Driver.new()
11
+ end
12
+
13
+ After('@TC_Google_Search') do
14
+ @@driver.quit
15
+ end
16
+
17
+ Given("I navigate to google search page") do
18
+ @@driver.get($param["googleURL"])
19
+ end
20
+
21
+ When("I type the term in google search bar and click on serach results") do
22
+ @@google_page.enter_text_and_search($param["searchTerm"])
23
+ end
24
+
25
+ Then("I should get the results page") do
26
+ expect(@@google_page.is_results_page_displayed?).to eql true
27
+ end
28
+
29
+ When("I type the {string} in google search bar and click on serach results") do |string|
30
+ @@google_page.enter_text_and_search(string)
31
+ end
@@ -0,0 +1,82 @@
1
+ require 'allure-cucumber'
2
+ require 'webdriver_manager'
3
+ require 'cucumber'
4
+ require 'require_all'
5
+ require 'pathname'
6
+ require 'fileutils'
7
+ require "pry"
8
+ require 'pry-remote'
9
+ require_rel "../locators/"
10
+ require_rel "../libraries/"
11
+ require_rel "../pages/"
12
+ require "time"
13
+ require 'faker'
14
+ require 'git'
15
+ require 'rest-client'
16
+ require 'json'
17
+ require 'parallel_tests'
18
+ require 'teber'
19
+
20
+ include AllureCucumber::DSL
21
+ include Teber
22
+ $VERBOSE = nil
23
+
24
+ if File.exist?('features/global-data/global.yml')
25
+ $conf = YAML.load_file('features/global-data/global.yml')
26
+ else
27
+ puts "features/global-data/global.yml is not found !!!"
28
+ end
29
+
30
+ AllureCucumber::configure do |c|
31
+ c.output_dir = "reports/allure"
32
+ c.clean_dir = true
33
+ end
34
+
35
+ Cucumber::Core::Test::Step.module_eval do
36
+ def name
37
+ return text if self.text == 'Before hook'
38
+ return text if self.text == 'After hook'
39
+ "#{source.last.keyword}#{text}"
40
+ end
41
+ end
42
+
43
+ Before do |scenario|
44
+ # Have the test data corresponding to a feature in the path `/features/test-data/` in the .conf format
45
+ # Name the file as same as the feature file and the below code will parse that file and have the variables in $param
46
+ # Test data specific to that feature can be accessed with $param in that step definition file.
47
+ feature = scenario.location
48
+ feature_file_name = feature.to_s.rpartition('/').last.split('.feature')[0]
49
+ test_variables_file_location = Dir.pwd + "/features/test-data/#{feature_file_name}.yml"
50
+ if File.exists?("#{test_variables_file_location}")
51
+ $param = YAML.load_file(test_variables_file_location)
52
+ end
53
+ end
54
+
55
+ After do |scenario|
56
+ if scenario.failed?
57
+ begin
58
+ drivers = Driver.get_all_drivers
59
+ drivers.each do |l,m|
60
+ Driver.switch_to(l)
61
+ scenario.attach_file(m,l.save_screenshot)
62
+ end
63
+ rescue Exception => e
64
+ puts e.message
65
+ puts e.backtrace
66
+ end
67
+ # to quit the test run if any one of the scenario is failed
68
+ end
69
+ end
70
+
71
+
72
+ at_exit do
73
+ # Moving the categories.json file from libraries to the allure folder
74
+ # rerun results are not shown with the categories in allure report.
75
+ # Raised an issue with allure-cucumber https://github.com/allure-framework/allure-cucumber/issues/83
76
+ if ParallelTests.first_process?
77
+ ParallelTests.wait_for_other_processes_to_finish
78
+ end
79
+ source_directory = Dir.pwd + "/features/libraries/categories.json"
80
+ destination_directory = Dir.pwd + "/reports/allure/"
81
+ `cp -a #{source_directory} #{destination_directory}`
82
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ searchTerm: hello
2
+ googleURL: https://www.google.com
@@ -0,0 +1,2 @@
1
+ searchTerm: hello
2
+ googleURL: https://www.google.com
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = %q{To have all the common methods that are used for UI automation, this enables us to share the methods across teams}
13
13
  spec.homepage = "https://nareshnavinash.wixsite.com/teber"
14
14
  spec.license = "GPL-3.0"
15
+ spec.executables << 'teber'
15
16
 
16
17
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
17
18
 
@@ -31,4 +32,15 @@ Gem::Specification.new do |spec|
31
32
  spec.add_development_dependency "bundler", "~> 2.0"
32
33
  spec.add_development_dependency "rake", "~> 10.0"
33
34
  spec.add_development_dependency "rspec", "~> 3.0"
35
+ spec.add_runtime_dependency 'selenium-webdriver', '3.142.6'
36
+ spec.add_runtime_dependency 'cucumber', '~> 3.1', '>= 3.1.2'
37
+ spec.add_runtime_dependency 'allure-cucumber', '~> 0.6.1'
38
+ spec.add_runtime_dependency 'rspec', '3.7.0'
39
+ spec.add_runtime_dependency 'parallel_tests', '2.21.0'
40
+ spec.add_runtime_dependency 'parseconfig', '1.0.8'
41
+ spec.add_runtime_dependency 'require_all', '~> 1.4', '>= 1.4.0'
42
+ spec.add_runtime_dependency 'os', '~> 0.9.6'
43
+ spec.add_runtime_dependency 'pry', '~> 0.10.4'
44
+ spec.add_runtime_dependency 'yaml_extend', '~> 0.2.0'
45
+ spec.add_runtime_dependency 'webdriver_manager', '~> 0.6.0'
34
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teber-library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naresh Sekar
@@ -52,14 +52,182 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: selenium-webdriver
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.142.6
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 3.142.6
69
+ - !ruby/object:Gem::Dependency
70
+ name: cucumber
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.1'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 3.1.2
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '3.1'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 3.1.2
89
+ - !ruby/object:Gem::Dependency
90
+ name: allure-cucumber
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.6.1
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.6.1
103
+ - !ruby/object:Gem::Dependency
104
+ name: rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '='
108
+ - !ruby/object:Gem::Version
109
+ version: 3.7.0
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '='
115
+ - !ruby/object:Gem::Version
116
+ version: 3.7.0
117
+ - !ruby/object:Gem::Dependency
118
+ name: parallel_tests
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '='
122
+ - !ruby/object:Gem::Version
123
+ version: 2.21.0
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '='
129
+ - !ruby/object:Gem::Version
130
+ version: 2.21.0
131
+ - !ruby/object:Gem::Dependency
132
+ name: parseconfig
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '='
136
+ - !ruby/object:Gem::Version
137
+ version: 1.0.8
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - '='
143
+ - !ruby/object:Gem::Version
144
+ version: 1.0.8
145
+ - !ruby/object:Gem::Dependency
146
+ name: require_all
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: 1.4.0
152
+ - - "~>"
153
+ - !ruby/object:Gem::Version
154
+ version: '1.4'
155
+ type: :runtime
156
+ prerelease: false
157
+ version_requirements: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: 1.4.0
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: '1.4'
165
+ - !ruby/object:Gem::Dependency
166
+ name: os
167
+ requirement: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: 0.9.6
172
+ type: :runtime
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - "~>"
177
+ - !ruby/object:Gem::Version
178
+ version: 0.9.6
179
+ - !ruby/object:Gem::Dependency
180
+ name: pry
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - "~>"
184
+ - !ruby/object:Gem::Version
185
+ version: 0.10.4
186
+ type: :runtime
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - "~>"
191
+ - !ruby/object:Gem::Version
192
+ version: 0.10.4
193
+ - !ruby/object:Gem::Dependency
194
+ name: yaml_extend
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: 0.2.0
200
+ type: :runtime
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - "~>"
205
+ - !ruby/object:Gem::Version
206
+ version: 0.2.0
207
+ - !ruby/object:Gem::Dependency
208
+ name: webdriver_manager
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - "~>"
212
+ - !ruby/object:Gem::Version
213
+ version: 0.6.0
214
+ type: :runtime
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - "~>"
219
+ - !ruby/object:Gem::Version
220
+ version: 0.6.0
55
221
  description: To have all the common methods that are used for UI automation, this
56
222
  enables us to share the methods across teams
57
223
  email:
58
224
  - nareshnavinash@gmail.com
59
- executables: []
225
+ executables:
226
+ - teber
60
227
  extensions: []
61
228
  extra_rdoc_files: []
62
229
  files:
230
+ - ".DS_Store"
63
231
  - ".gitignore"
64
232
  - ".rspec"
65
233
  - ".travis.yml"
@@ -73,12 +241,44 @@ files:
73
241
  - _config.yml
74
242
  - bin/console
75
243
  - bin/setup
244
+ - exe/teber
76
245
  - lib/teber.rb
77
246
  - lib/teber/Teber-Library-Gem.png
78
247
  - lib/teber/driver.rb
79
248
  - lib/teber/locator.rb
80
249
  - lib/teber/version.rb
81
250
  - lib/teber/wait.rb
251
+ - sample/.DS_Store
252
+ - sample/.gitignore
253
+ - sample/CONTRIBUTING.md
254
+ - sample/Gemfile
255
+ - sample/Gemfile.lock
256
+ - sample/LICENSE
257
+ - sample/README.md
258
+ - sample/_config.yml
259
+ - sample/config/cucumber.yml
260
+ - sample/features/.DS_Store
261
+ - sample/features/feature/.gitkeep
262
+ - sample/features/feature/googleSearch.feature
263
+ - sample/features/feature/googleSearchParallel.feature
264
+ - sample/features/global-data/.gitkeep
265
+ - sample/features/global-data/global.yml
266
+ - sample/features/libraries/.gitkeep
267
+ - sample/features/libraries/Teber_Ruby_Black.png
268
+ - sample/features/libraries/categories.json
269
+ - sample/features/libraries/driver.rb
270
+ - sample/features/libraries/locator.rb
271
+ - sample/features/libraries/wait.rb
272
+ - sample/features/locators/.gitkeep
273
+ - sample/features/locators/googleSearch.rb
274
+ - sample/features/pages/.gitkeep
275
+ - sample/features/pages/googleSearch.rb
276
+ - sample/features/step_definitions/.gitkeep
277
+ - sample/features/step_definitions/googleSearch.rb
278
+ - sample/features/support/env.rb
279
+ - sample/features/test-data/.gitkeep
280
+ - sample/features/test-data/googleSearch.yml
281
+ - sample/features/test-data/googleSearchParallel.yml
82
282
  - teber-library.gemspec
83
283
  homepage: https://nareshnavinash.wixsite.com/teber
84
284
  licenses: