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 +4 -4
- data/lib/Ifd_Automation/database_steps.rb +23 -19
- data/lib/Ifd_Automation/version.rb +1 -1
- data/lib/Ifd_Automation/web_steps.rb +22 -1
- data/lib/helper/connection_helpers.rb +3 -2
- data/lib/helper/core.rb +8 -20
- data/lib/helper/web_steps_helpers.rb +53 -0
- data/project/features/TestSuite/WebGUI.feature +1 -2
- data/project/features/step_definitions/lib_steps/actionwords.rb +12 -0
- data/project/features/step_definitions/lib_steps/test.rb +5 -9
- data/project/features/support/hooks.rb +53 -53
- data/project/tmp/TEST-features-TestSuite-WebGUI.xml +22 -0
- metadata +78 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e89d7a3697703ac7f56e4adea8d4440dc4947fa
|
4
|
+
data.tar.gz: 63595a4b3afd9c1dff2d4556640385ac8eda901d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
16
|
-
#
|
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
|
-
|
27
|
-
@result = @connection.connection
|
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
|
-
|
39
|
-
@result = @connection.connection
|
40
|
-
|
41
|
-
raise
|
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
|
@@ -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
|
-
|
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
|
-
|
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,
|
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
|
-
|
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
|
-
|
345
|
-
|
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
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
4
|
-
|
5
|
-
end
|
6
|
-
After('@IE') do
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
#Only run Chrome browser
|
11
|
-
Before('@CH') do
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
After('@CH') do
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
#Only run Firefox browser
|
20
|
-
Before('@FF') do
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
After('@FF') do
|
25
|
-
|
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.
|
42
|
-
#
|
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
|
-
#
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
+
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-
|
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
|