Ifd_Automation 2.4 → 2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c131081b7802a991c90b90514bd11afa74e9f2cc
4
- data.tar.gz: 8731f67ebf3ded3070b7cedad55bb752aa940981
3
+ metadata.gz: 7e89d7a3697703ac7f56e4adea8d4440dc4947fa
4
+ data.tar.gz: 63595a4b3afd9c1dff2d4556640385ac8eda901d
5
5
  SHA512:
6
- metadata.gz: 76dfdb6206a5e495f4620634b8452128fa4503dae989032b12bee5a1aa8ae375016611d72d21dfe5c592d0da98f0be4d5edaec7d1570e862552adac248f3d4d1
7
- data.tar.gz: 5d1a209eec045b56544a41e2333cc21208e8062b7a4afba29dc178262c7f0ce7207965aa1795aa833ba3dcfa6e45e37979955a7b22fce8df5e95a668110a96b0
6
+ metadata.gz: ccda095613322d9280fe0dadff32d27e77ac7f48ef93b3ab3fd61b0a2697191d9acdc152b6fe878156952f2ea265f4e36e9a6ccd2a6c60a6cd9af747ab5242fa
7
+ data.tar.gz: bb1c0beaca3fb55117e86660032b7d16f60e452aa4081750d77c992a4665fd06a763d4614a6be437bc3edd77880c9f234dadfdbd47aa127705a870b846342940
@@ -8,44 +8,48 @@ Given /^I create connection to database with:$/ do |data|
8
8
  data[k] = check_dynamic_value(v)
9
9
  end
10
10
  @connection = Connection.new(data)
11
- p "Connect to database successfully!" if @connection
11
+ put_log "Connect to database successfully!" if @connection
12
+ end
13
+ end
14
+ # NEW
15
+ When /^I close SQL connection$/ do
16
+ @connection.disconnect!
17
+ if !@connection.connected?
18
+ put_log "Disconnected to Database!"
12
19
  end
13
20
  end
14
21
 
15
- # Example
16
- # When I run multiple sql script:
17
- # """
18
- # delete from autofeatures where id=10;
19
- # delete from autofeatures where id=11;
20
- # """
21
- And /^I run multiple sql script:$/ do |raw_data|
22
- raw_data.strip!
23
- script = raw_data.split(/\n/)
24
- script.each do |row|
22
+
23
+ #NEW
24
+ And /^I run sql script:$/ do |raw_data|
25
25
  begin
26
- sql = "#{row}"
27
- @result = @connection.connection().execute(sql)
26
+ script = bind_with_dyn_vars(raw_data)
27
+ @result = @connection.connection.execute(script)
28
28
  rescue Exception => e
29
29
  raise e.message
30
30
  end
31
- end
31
+ # end
32
32
  end
33
33
 
34
34
  # Example
35
35
  # When I run sql script "select * from users where email=#{id}"
36
36
  And /^I run sql script "(.*)"$/ do |sql|
37
37
  script = check_dynamic_value sql
38
- begin
39
- @result = @connection.connection().execute(script)
40
- rescue Exception => e
41
- raise e.message
38
+ if @connection
39
+ @result = @connection.connection.execute(script)
40
+ else
41
+ raise "ERROR: Create connection to database first!"
42
42
  end
43
43
  end
44
44
 
45
45
  Then /^show me the result of SQL statement$/ do
46
46
  unless @result.nil?
47
+ p result.to_hash
48
+ for i in 0..@result
49
+ puts "\n SQL Result: #{i}"
50
+ end
47
51
  @result.each(:as => :hash) do |row|
48
- puts row
52
+ puts "----#{row}===="
49
53
  end
50
54
  end
51
55
  end
@@ -1,3 +1,3 @@
1
1
  module IfdAutomation
2
- VERSION = "2.4"
2
+ VERSION = "2.5"
3
3
  end
@@ -27,6 +27,12 @@ And /^I set text on "(.*?)" with "(.*?)"$/ do |object, text|
27
27
  execute_settext(object, text)
28
28
  end
29
29
 
30
+ # select option
31
+ And /^I select option on "(.*?)" with "(.*?)"$/ do |object, text|
32
+ execute_select(object, text)
33
+ end
34
+
35
+
30
36
  # step to maximize browser
31
37
  Then(/^I maximize browser window$/) do
32
38
  maximize_browser
@@ -55,4 +61,19 @@ end
55
61
  # step to assert javascript pop-up alert text
56
62
  Then(/^I should see alert text as "(.*?)"$/) do |actual_value|
57
63
  check_alert_text(actual_value)
58
- end
64
+ end
65
+
66
+ # NEW
67
+ Given /^I move mouse to element "(.*)" and click$/ do |object|
68
+ execute_mousehoverandclick(object)
69
+ end
70
+
71
+ # NEW
72
+ And /^remove attribute "(.*)" on object "(.*)"$/ do |attr, object|
73
+ remove_element_attribute object, attr
74
+ end
75
+
76
+ # set state for check box, combo box
77
+ And /^I set state on "(.*?)" with "(.*?)"$/ do |object, state|
78
+ execute_setstate(object, state)
79
+ end
@@ -1,10 +1,11 @@
1
- # require 'mysql2'
1
+ require 'tiny_tds'
2
+ require 'activerecord-sqlserver-adapter'
2
3
  require 'active_record'
3
4
 
4
5
  module Connection
5
6
  def self.new(connection_params)
6
7
  begin
7
- puts ("Connecting to MYSql database...")
8
+ put_log ("Connecting to database...")
8
9
  return ActiveRecord::Base.establish_connection(connection_params)
9
10
  rescue Exception => e
10
11
  raise e.message
data/lib/helper/core.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rspec'
1
2
  def check_dynamic_value value
2
3
  if !value.is_a? Fixnum
3
4
  if value.include? "params="
@@ -330,7 +331,7 @@ def execute_checkproperty element, property, negate, value, isSpecialChar=false
330
331
  config.ignore_hidden_elements = true
331
332
  end
332
333
 
333
- if Assertion.reg_compare(actual_value, value, isSpecialChar)
334
+ if Assertion.reg_compare(actual_value,value, isSpecialChar)
334
335
  check = true
335
336
  end
336
337
 
@@ -339,11 +340,13 @@ def execute_checkproperty element, property, negate, value, isSpecialChar=false
339
340
  if negate == " not"
340
341
  # check.should_not eq true
341
342
  # expect(check).not_to eql true
342
- !Assertion.assert_string_not_equal(actual_value,value)
343
+ actual_value.should_not eq value
344
+ expect(actual_value).not_to eql value
345
+ # !Assertion.assert_string_not_equal(actual_value,value)
343
346
  elsif
344
- # check.should eq true
345
- # expect(check).to eq true
346
- Assertion.assert_string_equal(actual_value,value)
347
+ actual_value.should eq value
348
+ expect(actual_value).to eq value
349
+ # Assertion.assert_string_equal(actual_value,value)
347
350
  end
348
351
  end
349
352
  end
@@ -495,18 +498,3 @@ def replace_pipe str_pipe
495
498
  end
496
499
  return str_pipe
497
500
  end
498
-
499
- # Select
500
- def execute_select element, text
501
- #select(text, :xpath => element)
502
- foundElement = find_object(element)
503
-
504
- if foundElement != nil
505
- option_value = page.evaluate_script("$(\"##{foundElement[:id]} option:contains('#{text}')\").val()")
506
- page.execute_script("$('##{foundElement[:id]}').val('#{option_value}')")
507
- page.execute_script("$('##{foundElement[:id]}').trigger('liszt:updated').trigger('change')")
508
- else
509
- put_log "\nError >> Not found object: #{element}"
510
- exit
511
- end
512
- end
@@ -120,4 +120,57 @@ def check_alert_text(text)
120
120
  if alert != text
121
121
  raise "Text on alert pop up not matched, Actual Text : #{alert}, Expected Text : #{text}"
122
122
  end
123
+ end
124
+
125
+
126
+ # Select
127
+ def execute_select element, text
128
+ #select(text, :xpath => element)
129
+ foundElement = find_object(element)
130
+
131
+ if foundElement != nil
132
+ option_value = page.evaluate_script("$(\"##{foundElement[:id]} option:contains('#{text}')\").val()")
133
+ page.execute_script("$('##{foundElement[:id]}').val('#{option_value}')")
134
+ page.execute_script("$('##{foundElement[:id]}').trigger('liszt:updated').trigger('change')")
135
+ else
136
+ put_log "\nError >> Not found object: #{element}"
137
+ exit
138
+ end
139
+ end
140
+
141
+ def execute_mousehoverandclick element
142
+ foundElement = find_object(element)
143
+ if foundElement != nil
144
+ # page.driver.browser.mouse.move_to(foundElement.native, element)
145
+ # page.driver.browser.mouse.click(foundElement.native)
146
+ page.driver.browser.action.move_to(foundElement.native, element).click.perform
147
+ # driver.action.move_to(foundElement.native).click
148
+ sleep(2)
149
+ else
150
+ put_log "\nError >> Not found object: #{element}"
151
+ end
152
+ end
153
+
154
+ def remove_element_attribute element, attr
155
+ foundElement = find_object(element)
156
+ if foundElement != nil
157
+ page.driver.browser.execute_script("arguments[0].removeAttribute('#{attr}');", foundElement.native)
158
+ else
159
+ put_log "\nError >> Not found object: #{element}"
160
+ end
161
+ end
162
+
163
+ # Set state
164
+ def execute_setstate element, state
165
+ foundElement = find_object(element)
166
+ if foundElement != nil
167
+ if state.upcase == "TRUE"
168
+ foundElement.select_option
169
+ else
170
+ foundElement.unselect_option
171
+ end
172
+ else
173
+ put_log "\nError >> Not found object: #{element}"
174
+ exit
175
+ end
123
176
  end
@@ -1,5 +1,4 @@
1
1
  Feature: Example feature for GUI testing
2
2
 
3
3
  Scenario: testing case for web interaction
4
- Given I login to the page "params='testpage'" with username "anhpq.info@gmail.com" and password "a123"
5
- * I check property "login.label_message_error" with "text" has value "Account does not exist"
4
+ Given I login to the system with user and pass "http://google.com" "test" "test"
@@ -0,0 +1,12 @@
1
+ module Actionwords
2
+ def login_to_system_with_user_and_pass(url,user,pass)
3
+ steps %Q{
4
+ * I am on the "#{url}" page
5
+ * I click on "header.button_cookie"
6
+ * I click on "header.button_login"
7
+ * I set text on "login.textbox_username" with "#{user}"
8
+ * I set text on "login.textbox_password" with "#{pass}"
9
+ * I click on "login.button_login"
10
+ }
11
+ end
12
+ end
@@ -1,10 +1,6 @@
1
- Given "I login to the page {string} with username {string} and password {string}" do |string, string2, string3|
2
- steps %Q{
3
- * I am on the "#{string}" page
4
- * I click on "header.button_cookie"
5
- * I click on "header.button_login"
6
- * I set text on "login.textbox_username" with "#{string2}"
7
- * I set text on "login.textbox_password" with "#{string3}"
8
- * I click on "login.button_login"
9
- }
1
+ require_relative 'actionwords'
2
+ World(Actionwords)
3
+
4
+ Given /I login to the system with user and pass "(.*)" "(.*)" "(.*)"/ do |url, user, pass|
5
+ login_to_system_with_user_and_pass(url,user,pass)
10
6
  end
@@ -1,59 +1,59 @@
1
- #Only run IE browser
2
- Before('@IE') do
3
- $_Old_Default_Browser = $_CFWEB['Default Browser']
4
- $_CFWEB['Default Browser'] = 'IE'
5
- end
6
- After('@IE') do
7
- $_CFWEB['Default Browser'] = $_Old_Default_Browser
8
- end
9
-
10
- #Only run Chrome browser
11
- Before('@CH') do
12
- $_Old_Default_Browser = $_CFWEB['Default Browser']
13
- $_CFWEB['Default Browser'] = 'CH'
14
- end
15
- After('@CH') do
16
- $_CFWEB['Default Browser'] = $_Old_Default_Browser
17
- end
18
-
19
- #Only run Firefox browser
20
- Before('@FF') do
21
- $_Old_Default_Browser = $_CFWEB['Default Browser']
22
- $_CFWEB['Default Browser'] = 'FF'
23
- end
24
- After('@FF') do
25
- $_CFWEB['Default Browser'] = $_Old_Default_Browser
26
- end
27
-
28
- Before do
29
- begin
30
- browser = Capybara.current_session.driver.browser
31
- browser.manage.delete_all_cookies
32
- rescue StandardError => myStandardError
33
- put_log "\n>>> Error: #{myStandardError}"
34
- end
35
- end
36
-
37
- # After do |scenario|
38
- # file_name = 'failed_%s.png' % rand(1000).to_s
39
- # page.save_screenshot($screenshot+file_name) if scenario.failed?
1
+ # #Only run IE browser
2
+ # Before('@IE') do
3
+ # $_Old_Default_Browser = $_CFWEB['Default Browser']
4
+ # $_CFWEB['Default Browser'] = 'IE'
5
+ # end
6
+ # After('@IE') do
7
+ # $_CFWEB['Default Browser'] = $_Old_Default_Browser
8
+ # end
9
+ #
10
+ # #Only run Chrome browser
11
+ # Before('@CH') do
12
+ # $_Old_Default_Browser = $_CFWEB['Default Browser']
13
+ # $_CFWEB['Default Browser'] = 'CH'
14
+ # end
15
+ # After('@CH') do
16
+ # $_CFWEB['Default Browser'] = $_Old_Default_Browser
17
+ # end
18
+ #
19
+ # #Only run Firefox browser
20
+ # Before('@FF') do
21
+ # $_Old_Default_Browser = $_CFWEB['Default Browser']
22
+ # $_CFWEB['Default Browser'] = 'FF'
23
+ # end
24
+ # After('@FF') do
25
+ # $_CFWEB['Default Browser'] = $_Old_Default_Browser
26
+ # end
27
+ #
28
+ # Before do
40
29
  # begin
41
- # Capybara.page.driver.quit
42
- # Capybara.send(:session_pool).delete_if { |key, value| key =~ /selenium/i }
30
+ # browser = Capybara.current_session.driver.browser
31
+ # browser.manage.delete_all_cookies
43
32
  # rescue StandardError => myStandardError
44
33
  # put_log "\n>>> Error: #{myStandardError}"
45
34
  # end
46
35
  # end
47
36
  #
48
- # at_exit do
49
- # end
50
-
51
- AfterConfiguration do |config|
52
- end
53
-
54
- Around do |scenario, block|
55
- block.call
56
- end
57
-
58
- AfterStep do |scenario|
59
- end
37
+ # # After do |scenario|
38
+ # # file_name = 'failed_%s.png' % rand(1000).to_s
39
+ # # page.save_screenshot($screenshot+file_name) if scenario.failed?
40
+ # # begin
41
+ # # Capybara.page.driver.quit
42
+ # # Capybara.send(:session_pool).delete_if { |key, value| key =~ /selenium/i }
43
+ # # rescue StandardError => myStandardError
44
+ # # put_log "\n>>> Error: #{myStandardError}"
45
+ # # end
46
+ # # end
47
+ # #
48
+ # # at_exit do
49
+ # # end
50
+ #
51
+ # AfterConfiguration do |config|
52
+ # end
53
+ #
54
+ # Around do |scenario, block|
55
+ # block.call
56
+ # end
57
+ #
58
+ # AfterStep do |scenario|
59
+ # end
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite failures="1" errors="0" skipped="0" tests="1" time="0.054199" name="Example feature for GUI testing">
3
+ <testcase classname="Example feature for GUI testing" name="testing case for web interaction" time="0.054199">
4
+ <failure message="failed testing case for web interaction" type="failed">
5
+ <![CDATA[Scenario: testing case for web interaction
6
+
7
+ Given I print the value of "ad"
8
+
9
+ Message:
10
+ ]]>
11
+ <![CDATA[undefined local variable or method `ad' for #<Object:0x63e6b68> (NameError)
12
+ features/TestSuite/WebGUI.feature:7:in `Given I print the value of "ad"']]>
13
+ </failure>
14
+ <system-out>
15
+ <![CDATA["-asdfas"
16
+ ]]>
17
+ </system-out>
18
+ <system-err>
19
+ <![CDATA[]]>
20
+ </system-err>
21
+ </testcase>
22
+ </testsuite>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ifd_Automation
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.4'
4
+ version: '2.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anh Pham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-25 00:00:00.000000000 Z
11
+ date: 2018-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -146,6 +146,80 @@ dependencies:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
148
  version: 2.11.1
149
+ - !ruby/object:Gem::Dependency
150
+ name: activerecord
151
+ requirement: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '='
154
+ - !ruby/object:Gem::Version
155
+ version: 5.1.5
156
+ type: :runtime
157
+ prerelease: false
158
+ version_requirements: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - '='
161
+ - !ruby/object:Gem::Version
162
+ version: 5.1.5
163
+ - !ruby/object:Gem::Dependency
164
+ name: tiny_tds
165
+ requirement: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '2.1'
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: 2.1.1
173
+ type: :runtime
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '2.1'
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: 2.1.1
183
+ - !ruby/object:Gem::Dependency
184
+ name: activerecord-sqlserver-adapter
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: '5.1'
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: 5.1.6
193
+ type: :runtime
194
+ prerelease: false
195
+ version_requirements: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: '5.1'
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: 5.1.6
203
+ - !ruby/object:Gem::Dependency
204
+ name: rspec
205
+ requirement: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: 3.7.0
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: 3.7.0
213
+ type: :runtime
214
+ prerelease: false
215
+ version_requirements: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - "~>"
218
+ - !ruby/object:Gem::Version
219
+ version: 3.7.0
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: 3.7.0
149
223
  description: Behavior driven development (BDD) approach to write automation test script
150
224
  to test GUI, RESTful, SOAP, Database, eMail.
151
225
  email:
@@ -183,10 +257,12 @@ files:
183
257
  - project/features/Screenshot/sample.jpg
184
258
  - project/features/TestData/globalData.yml
185
259
  - project/features/TestSuite/WebGUI.feature
260
+ - project/features/step_definitions/lib_steps/actionwords.rb
186
261
  - project/features/step_definitions/lib_steps/test.rb
187
262
  - project/features/step_definitions/repositories/project_object.yml
188
263
  - project/features/support/env.rb
189
264
  - project/features/support/hooks.rb
265
+ - project/tmp/TEST-features-TestSuite-WebGUI.xml
190
266
  homepage: http://rubygems.org/gems/ifd_automation
191
267
  licenses:
192
268
  - MIT