awetestlib 0.1.30pre1-x86-mingw32 → 0.1.30pre2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,70 +1,70 @@
1
- awetestlib*.gem
2
- *.csv
3
-
4
- # gVim tmp files
5
- *~
6
- # rcov generated
7
- coverage
8
-
9
- # rdoc generated
10
- rdoc
11
-
12
- # yard generated
13
- doc
14
- .yardoc
15
-
16
- # bundler
17
- .bundle
18
- Gemfile.lock
19
-
20
- # jeweler generated
21
- pkg
22
-
23
- # for windows
24
- Thumb.db
25
-
26
- # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
27
- #
28
- # * Create a file at ~/.gitignore
29
- # * Include files you want ignored
30
- # * Run: git config --global core.excludesfile ~/.gitignore
31
- #
32
- # After doing this, these files will be ignored in all your git projects,
33
- # saving you from having to 'pollute' every project you touch with them
34
- #
35
- # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
36
- #
37
- # For MacOS:
38
- #
39
- .DS_Store
40
- tmp/*
41
- .rvmrc
42
-
43
- # For TextMate
44
- #*.tmproj
45
- #tmtags
46
-
47
- # For emacs:
48
- #*~
49
- #\#*
50
- #.\#*
51
-
52
- # For vim:
53
- *.sw[onp]
54
-
55
- # For redcar:
56
- #.redcar
57
-
58
- # For rubinius:
59
- #*.rbc
60
-
61
- config/win2008.txt
62
-
63
- __MACOSX/
64
- short_passing_test/
65
- dump.rdb
66
- .idea
67
- config/settings.yml
68
- PROJECT_NAME
69
- *.log
70
- awetest_reports/
1
+ awetestlib*.gem
2
+ *.csv
3
+
4
+ # gVim tmp files
5
+ *~
6
+ # rcov generated
7
+ coverage
8
+
9
+ # rdoc generated
10
+ rdoc
11
+
12
+ # yard generated
13
+ doc
14
+ .yardoc
15
+
16
+ # bundler
17
+ .bundle
18
+ Gemfile.lock
19
+
20
+ # jeweler generated
21
+ pkg
22
+
23
+ # for windows
24
+ Thumb.db
25
+
26
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
27
+ #
28
+ # * Create a file at ~/.gitignore
29
+ # * Include files you want ignored
30
+ # * Run: git config --global core.excludesfile ~/.gitignore
31
+ #
32
+ # After doing this, these files will be ignored in all your git projects,
33
+ # saving you from having to 'pollute' every project you touch with them
34
+ #
35
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
36
+ #
37
+ # For MacOS:
38
+ #
39
+ .DS_Store
40
+ tmp/*
41
+ .rvmrc
42
+
43
+ # For TextMate
44
+ #*.tmproj
45
+ #tmtags
46
+
47
+ # For emacs:
48
+ #*~
49
+ #\#*
50
+ #.\#*
51
+
52
+ # For vim:
53
+ *.sw[onp]
54
+
55
+ # For redcar:
56
+ #.redcar
57
+
58
+ # For rubinius:
59
+ #*.rbc
60
+
61
+ config/win2008.txt
62
+
63
+ __MACOSX/
64
+ short_passing_test/
65
+ dump.rdb
66
+ .idea
67
+ config/settings.yml
68
+ PROJECT_NAME
69
+ *.log
70
+ awetest_reports/
@@ -1,173 +1,173 @@
1
- module Awetestlib
2
- # Report generator for Awetestlib.
3
- class HtmlReport
4
-
5
- # Initialize the report class
6
- # @private
7
- def initialize(report_name)
8
- @reportname = report_name
9
- @reportContent1 = ''
10
- @reportContent2 = ''
11
- end
12
-
13
- # Create a report
14
- # @private
15
- def create_report(reportName)
16
- # Get current time
17
- t = Time.now
18
-
19
- @col_1_p = '65%'
20
- @col_2_p = '25%'
21
- @col_3_p = '10%'
22
-
23
- # Create the report name
24
- rpt_time = "#{t.strftime("%Y%m%d_%H%M%S")}"
25
- rpt_nice_time = "#{t.strftime("%m/%d/%Y @ %H:%M:%S")}"
26
- rpt_file_name = "#{reportName}_#{rpt_time}.html"
27
-
28
- # Create the HTML report
29
- rpt_file = File.open(rpt_file_name, 'w')
30
-
31
- # Format the header of the HTML report
32
- @reportContent1 = '<html>
33
- <head>
34
- <meta content=text/html; charset=ISO-8859-1 http-equiv=content-type>
35
- <title>Awetestlib Test Run</title>
36
- <style type=text/css>
37
- .title { font-family: verdana; font-size: 30px; font-weight: bold; align: left; color: #000000;}
38
- .bold_text { font-family: verdana; font-size: 11px; font-weight: bold;}
39
- .bold_large_text { font-family: verdana; font-size: 12px; font-weight: bold;}
40
- .normal_text { font-family: verdana; font-size: 11px; font-weight: normal;}
41
- .center_text { font-family: verdana; font-size: 11px; font-weight: normal; text-align: center;}
42
- .small_text { font-family: verdana; font-size: 9px; font-weight: normal; }
43
- .border { border: 1px solid #000000;}
44
- .mark_testlevel_left { border-top: 1px solid #858585; border-left: 1px solid #858585;background-color:#E2F4FE;}
45
- .mark_testlevel_middle { border-top: 1px solid #858585; background-color:#E2F4FE;}
46
- .mark_testlevel_right { border-top: 1px solid #858585; border-right: 1px solid #858585;background-color:#E2F4FE;}
47
- .border_left { border-top: 1px solid #858585; border-left: 1px solid #858585; border-right: 1px solid #858585;}
48
- .border_middle { border-top: 1px solid #858585; border-right: 1px solid #858585;}
49
- .border_right { border-top: 1px solid #858585; border-right: 1px solid #858585;}
50
- .result_ok { font-family: verdana; font-size: 11px; font-weight: bold; text-align: center; color: green;}
51
- .result_nok { font-family: verdana; font-size: 11px; font-weight: bold; text-align: center; color: red;}
52
- .overall_ok { font-family: verdana; font-size: 11px; font-weight: bold; text-align: left; color: green;}
53
- .overall_nok { font-family: verdana; font-size: 11px; font-weight: bold; text-align: left; color: red;}
54
- .bborder_left { border-top: 1px solid #858585; border-left: 1px solid #858585; border-bottom: 1px solid #858585; background-color:#858585;font-family: verdana; font-size: 12px; font-weight: bold; text-align: center; color: white;}
55
- .bborder_right { border-right: 1px solid #858585; background-color:#858585;font-family: verdana; font-size: 12px; font-weight: bold; text-align: center; color: white;}
56
- </style>
57
- </head>
58
- <body>
59
- <br>
60
- <center>
61
- <table width=auto border=0 cellpadding=2 cellspacing=2>
62
- <tbody>
63
- <tr>
64
- <td>
65
- <table width=90% border=0 cellpadding=2 cellspacing=2>
66
- <tbody>
67
- <tr>
68
- <td style=width: 150px;>&nbsp;</td>
69
- <td align=left><img src="https://raw.github.com/3qilabs/awetestlib/develop/images/logo.png"></img></td>
70
- <td align=right><p class=title>Test Report</p></td>
71
- </tr>
72
- </tbody>
73
- </table>
74
- <br>
75
- <hr width=100% class=border size=1px>
76
- <center>
77
- <table border=0 width=100% cellpadding=2 cellspacing=2>
78
- <tbody>
79
- <tr>
80
- <td width=10%><p class=normal_text></p></td>
81
- <td width=20%><p class=bold_text>Script</p></td>
82
- <td width=5%><p class=bold_text>:</p></td>
83
- <td width=65%><p class=normal_text>' + @reportname.capitalize + '</p></td>
84
- </tr>
85
- <tr>
86
- <td width=10%><p class=normal_text></p></td>
87
- <td width=20%><p class=bold_text>Test Execution</p></td>
88
- <td width=5%><p class=bold_text>:</p></td>
89
- <td width=65%><p class=normal_text>' + rpt_nice_time + '</p></td>
90
- </tr>
91
- <tr>'
92
-
93
- @reportContent2 = '</tr>
94
- </tbody>
95
- </table>
96
- </center>
97
- <br>
98
- <center>
99
- <table width=100% cellpadding=2 cellspacing=0>
100
- <tbody>
101
- <tr>
102
- <td class=bborder_left width=' + @col_1_p + '><p>Test Step</p></td>
103
- <td class=bborder_left width=' + @col_2_p + '><p>Location</p></td>
104
- <td class=bborder_left width=' + @col_3_p + '><p>Result</p></td>
105
- </tr>' + "\n"
106
-
107
- # Close the report
108
- rpt_file.close
109
-
110
- return rpt_file_name
111
- end
112
-
113
- # Add a row to the report
114
- # @private
115
- def add_to_report(message, location, result, level = 1)
116
- # Format the body of the HTML report
117
-
118
- left_class = 'border_left'
119
- right_class = 'border_right'
120
- pgph_class = 'normal_text'
121
- loc_class = 'center_text'
122
- rslt_class = 'result_ok'
123
- middle_class = 'border_middle'
124
-
125
- rslt_class = 'result_nok' if result == "FAILED"
126
- case result
127
- when 'FAILED'
128
- rslt_class = 'result_nok'
129
- when 'PASSED'
130
- rslt_class = 'result_ok'
131
- else
132
- if level
133
- if level >= 1
134
- pgph_class = 'bold_large_text'
135
- left_class = 'mark_testlevel_left'
136
- middle_class = 'mark_testlevel_middle'
137
- right_class = 'mark_testlevel_right'
138
- end
139
- end
140
- end
141
-
142
- row = '<tr>
143
- <td class=' + left_class + ' width=' + @col_1_p + '><p class=' + pgph_class + '>' + message + '</p></td>
144
- <td class=' + middle_class + ' width=' + @col_2_p + '><p class=' + loc_class + '>' + location + '</p></td>
145
- <td class=' + right_class + ' width=' + @col_3_p + '><p class=' + rslt_class + '>' + result + '</p></td>
146
- </tr>'
147
-
148
- @reportContent2 += row + "\n"
149
-
150
- end
151
-
152
- # Close the report HTML
153
- # @private
154
- def finish_report(reportName)
155
- # Open the HTML report
156
- rpt_file = File.open(reportName, 'a')
157
-
158
- @reportContent2 = @reportContent2 + '<tr>
159
- <td class=bborder_left width=' + @col_1_p + '><p>&nbsp;</p></td>
160
- <td class=bborder_left width=' + @col_2_p + '><p>&nbsp;</p></td>
161
- <td class=bborder_left width=' + @col_3_p + '><p>&nbsp;</p></td>
162
- </tr>
163
- </table>'
164
-
165
- rpt_file.puts(@reportContent1)
166
-
167
- rpt_file.puts(@reportContent2)
168
-
169
- # Close the report
170
- rpt_file.close
171
- end
172
- end
173
- end
1
+ module Awetestlib
2
+ # Report generator for Awetestlib.
3
+ class HtmlReport
4
+
5
+ # Initialize the report class
6
+ # @private
7
+ def initialize(report_name)
8
+ @reportname = report_name
9
+ @reportContent1 = ''
10
+ @reportContent2 = ''
11
+ end
12
+
13
+ # Create a report
14
+ # @private
15
+ def create_report(reportName)
16
+ # Get current time
17
+ t = Time.now
18
+
19
+ @col_1_p = '65%'
20
+ @col_2_p = '25%'
21
+ @col_3_p = '10%'
22
+
23
+ # Create the report name
24
+ rpt_time = "#{t.strftime("%Y%m%d_%H%M%S")}"
25
+ rpt_nice_time = "#{t.strftime("%m/%d/%Y @ %H:%M:%S")}"
26
+ rpt_file_name = "#{reportName}_#{rpt_time}.html"
27
+
28
+ # Create the HTML report
29
+ rpt_file = File.open(rpt_file_name, 'w')
30
+
31
+ # Format the header of the HTML report
32
+ @reportContent1 = '<html>
33
+ <head>
34
+ <meta content=text/html; charset=ISO-8859-1 http-equiv=content-type>
35
+ <title>Awetestlib Test Run</title>
36
+ <style type=text/css>
37
+ .title { font-family: verdana; font-size: 30px; font-weight: bold; align: left; color: #000000;}
38
+ .bold_text { font-family: verdana; font-size: 11px; font-weight: bold;}
39
+ .bold_large_text { font-family: verdana; font-size: 12px; font-weight: bold;}
40
+ .normal_text { font-family: verdana; font-size: 11px; font-weight: normal;}
41
+ .center_text { font-family: verdana; font-size: 11px; font-weight: normal; text-align: center;}
42
+ .small_text { font-family: verdana; font-size: 9px; font-weight: normal; }
43
+ .border { border: 1px solid #000000;}
44
+ .mark_testlevel_left { border-top: 1px solid #858585; border-left: 1px solid #858585;background-color:#E2F4FE;}
45
+ .mark_testlevel_middle { border-top: 1px solid #858585; background-color:#E2F4FE;}
46
+ .mark_testlevel_right { border-top: 1px solid #858585; border-right: 1px solid #858585;background-color:#E2F4FE;}
47
+ .border_left { border-top: 1px solid #858585; border-left: 1px solid #858585; border-right: 1px solid #858585;}
48
+ .border_middle { border-top: 1px solid #858585; border-right: 1px solid #858585;}
49
+ .border_right { border-top: 1px solid #858585; border-right: 1px solid #858585;}
50
+ .result_ok { font-family: verdana; font-size: 11px; font-weight: bold; text-align: center; color: green;}
51
+ .result_nok { font-family: verdana; font-size: 11px; font-weight: bold; text-align: center; color: red;}
52
+ .overall_ok { font-family: verdana; font-size: 11px; font-weight: bold; text-align: left; color: green;}
53
+ .overall_nok { font-family: verdana; font-size: 11px; font-weight: bold; text-align: left; color: red;}
54
+ .bborder_left { border-top: 1px solid #858585; border-left: 1px solid #858585; border-bottom: 1px solid #858585; background-color:#858585;font-family: verdana; font-size: 12px; font-weight: bold; text-align: center; color: white;}
55
+ .bborder_right { border-right: 1px solid #858585; background-color:#858585;font-family: verdana; font-size: 12px; font-weight: bold; text-align: center; color: white;}
56
+ </style>
57
+ </head>
58
+ <body>
59
+ <br>
60
+ <center>
61
+ <table width=auto border=0 cellpadding=2 cellspacing=2>
62
+ <tbody>
63
+ <tr>
64
+ <td>
65
+ <table width=90% border=0 cellpadding=2 cellspacing=2>
66
+ <tbody>
67
+ <tr>
68
+ <td style=width: 150px;>&nbsp;</td>
69
+ <td align=left><img src="https://raw.github.com/3qilabs/awetestlib/develop/images/logo.png"></img></td>
70
+ <td align=right><p class=title>Test Report</p></td>
71
+ </tr>
72
+ </tbody>
73
+ </table>
74
+ <br>
75
+ <hr width=100% class=border size=1px>
76
+ <center>
77
+ <table border=0 width=100% cellpadding=2 cellspacing=2>
78
+ <tbody>
79
+ <tr>
80
+ <td width=10%><p class=normal_text></p></td>
81
+ <td width=20%><p class=bold_text>Script</p></td>
82
+ <td width=5%><p class=bold_text>:</p></td>
83
+ <td width=65%><p class=normal_text>' + @reportname.capitalize + '</p></td>
84
+ </tr>
85
+ <tr>
86
+ <td width=10%><p class=normal_text></p></td>
87
+ <td width=20%><p class=bold_text>Test Execution</p></td>
88
+ <td width=5%><p class=bold_text>:</p></td>
89
+ <td width=65%><p class=normal_text>' + rpt_nice_time + '</p></td>
90
+ </tr>
91
+ <tr>'
92
+
93
+ @reportContent2 = '</tr>
94
+ </tbody>
95
+ </table>
96
+ </center>
97
+ <br>
98
+ <center>
99
+ <table width=100% cellpadding=2 cellspacing=0>
100
+ <tbody>
101
+ <tr>
102
+ <td class=bborder_left width=' + @col_1_p + '><p>Test Step</p></td>
103
+ <td class=bborder_left width=' + @col_2_p + '><p>Location</p></td>
104
+ <td class=bborder_left width=' + @col_3_p + '><p>Result</p></td>
105
+ </tr>' + "\n"
106
+
107
+ # Close the report
108
+ rpt_file.close
109
+
110
+ return rpt_file_name
111
+ end
112
+
113
+ # Add a row to the report
114
+ # @private
115
+ def add_to_report(message, location, result, level = 1)
116
+ # Format the body of the HTML report
117
+
118
+ left_class = 'border_left'
119
+ right_class = 'border_right'
120
+ pgph_class = 'normal_text'
121
+ loc_class = 'center_text'
122
+ rslt_class = 'result_ok'
123
+ middle_class = 'border_middle'
124
+
125
+ rslt_class = 'result_nok' if result == "FAILED"
126
+ case result
127
+ when 'FAILED'
128
+ rslt_class = 'result_nok'
129
+ when 'PASSED'
130
+ rslt_class = 'result_ok'
131
+ else
132
+ if level
133
+ if level >= 1
134
+ pgph_class = 'bold_large_text'
135
+ left_class = 'mark_testlevel_left'
136
+ middle_class = 'mark_testlevel_middle'
137
+ right_class = 'mark_testlevel_right'
138
+ end
139
+ end
140
+ end
141
+
142
+ row = '<tr>
143
+ <td class=' + left_class + ' width=' + @col_1_p + '><p class=' + pgph_class + '>' + message + '</p></td>
144
+ <td class=' + middle_class + ' width=' + @col_2_p + '><p class=' + loc_class + '>' + location + '</p></td>
145
+ <td class=' + right_class + ' width=' + @col_3_p + '><p class=' + rslt_class + '>' + result + '</p></td>
146
+ </tr>'
147
+
148
+ @reportContent2 += row + "\n"
149
+
150
+ end
151
+
152
+ # Close the report HTML
153
+ # @private
154
+ def finish_report(reportName)
155
+ # Open the HTML report
156
+ rpt_file = File.open(reportName, 'a')
157
+
158
+ @reportContent2 = @reportContent2 + '<tr>
159
+ <td class=bborder_left width=' + @col_1_p + '><p>&nbsp;</p></td>
160
+ <td class=bborder_left width=' + @col_2_p + '><p>&nbsp;</p></td>
161
+ <td class=bborder_left width=' + @col_3_p + '><p>&nbsp;</p></td>
162
+ </tr>
163
+ </table>'
164
+
165
+ rpt_file.puts(@reportContent1)
166
+
167
+ rpt_file.puts(@reportContent2)
168
+
169
+ # Close the report
170
+ rpt_file.close
171
+ end
172
+ end
173
+ end
@@ -14,7 +14,7 @@ require 'awetestlib/html_report' #; load_time
14
14
  require 'ostruct' #; load_time
15
15
  require 'active_support' #; load_time
16
16
  require 'active_support/inflector' #; load_time
17
- require 'sys/uname' #; load_time
17
+ #require 'sys/uname' #; load_time
18
18
 
19
19
  module Awetestlib
20
20
  module Regression
@@ -22,7 +22,7 @@ module Awetestlib
22
22
  class Runner < Awetestlib::Runner
23
23
 
24
24
  # order matters here
25
- include Sys #; load_time('include Sys')
25
+ # include Sys #; load_time('include Sys')
26
26
  include ActiveSupport::Inflector #; load_time('include ActiveSupport::Inflector')
27
27
  include Awetestlib::Logging #; load_time('include Awetestlib::Logging')
28
28
  include Awetestlib::Regression::Utilities #; load_time('include Awetestlib::Regression::Utilities')
@@ -269,7 +269,7 @@ module Awetestlib
269
269
  end
270
270
 
271
271
  def start
272
- get_os
272
+ #get_os
273
273
  before_run
274
274
  run
275
275
  rescue Exception => e
data/lib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
- module Awetestlib
2
- VERSION = "0.1.30pre1"
3
- VERSION_DATE = "2013-05-02"
4
- end
1
+ module Awetestlib
2
+ VERSION = "0.1.30pre2"
3
+ VERSION_DATE = "2013-05-03"
4
+ end
@@ -1,354 +1,354 @@
1
- require 'pry'
2
-
3
- def awetestlib?
4
- not Awetestlib::Runner.nil?
5
- rescue
6
- return false
7
- end
8
-
9
- Given /^I run with Watir$/ do
10
- require 'watir'
11
- require 'win32ole'
12
- $ai = ::WIN32OLE.new('AutoItX3.Control')
13
- $first_index = 1
14
- $timestamp = Time.now.strftime("%Y%m%d%H%M%S")
15
- $watir_script = true
16
- Watir::IE.close_all
17
- Watir::IE.visible = true
18
- end
19
-
20
- Given /^I run with Classic Watir$/ do
21
- step "I run with Watir"
22
- end
23
-
24
- Given /^I run with Watir-webdriver$/i do
25
- require 'watir-webdriver'
26
- $first_index = 0
27
- $timestamp = Time.now.strftime("%Y%m%d%H%M%S")
28
- $watir_script = false
29
- end
30
-
31
-
32
- When /^I open a new browser$/i do
33
- if @params
34
- puts "@params: #{@params}"
35
- case @params["browser"]
36
- when "FF"
37
- step "I open Firefox"
38
- when "IE"
39
- step "I open Internet Explorer"
40
- when "C", "GC"
41
- step "I open Chrome"
42
- end
43
- else
44
- step "I open Firefox"
45
- end
46
- end
47
-
48
- Given /^I open a F?f?irefox B?b?rowser$/i do
49
- step "I open Firefox"
50
- end
51
-
52
- Given /^I open Firefox$/ do
53
- step "I run with Watir-webdriver"
54
- @browser = Watir::Browser.new :firefox
55
- end
56
-
57
- Given /^I open a C?c?hrome B?b?rowser$/i do
58
- step "I open Chrome"
59
- end
60
-
61
- Given /^I open Chrome$/ do
62
- step "I run with Watir-webdriver"
63
- @browser = Watir::Browser.new :chrome
64
- end
65
-
66
- When /^I open an IE B?b?rowser$/i do
67
- step "I open Internet Explorer"
68
- end
69
-
70
- Given /^I open an I?i?nternet E?e?xplorer B?b?rowser$/i do
71
- step "I open Internet Explorer"
72
- end
73
-
74
- Given /^I open Internet Explorer$/i do
75
- if $watir_script
76
- step "I run with Watir"
77
- @browser = Watir::IE.new
78
- @browser.speed = :fast
79
- else
80
- step "I run with Watir-webdriver"
81
- client = Selenium::WebDriver::Remote::Http::Default.new
82
- client.timeout = 300 # seconds – default is 60
83
- @browser = Watir::Browser.new :ie, :http_client => client
84
- end
85
- end
86
-
87
- Then /^I navigate to the environment url$/ do
88
- if @params and @params['environment'] and @params['environment']['url']
89
- url = @params['environment']['url']
90
- elsif @login and @login['url']
91
- url = @login['url']
92
- elsif @role and @login[@role] and @login[@role]['url']
93
- url = @login[@role]['url']
94
- end
95
- @browser.goto url
96
- end
97
-
98
- Then /^I go to the url "(.*?)"$/ do |url|
99
- @browser.goto url
100
- end
101
-
102
- Then /^I go to the (URL|url)$/ do |dummy|
103
- step "I navigate to the environment url"
104
- end
105
-
106
- Then /^I click "(.*?)"$/ do |element_text|
107
- step "I click the element with \"text\" \"#{element_text}\""
108
- end
109
-
110
- Then /^I click the button "(.*?)"$/ do |element_text|
111
- step "I click the button with \"text\" \"#{element_text}\""
112
- end
113
-
114
- Then /^I click the "?(.*?)"? with "(.*?)" "(.*?)"$/ do |element, how, what|
115
- step "I wait until #{element} with #{how} \"#{what}\" is ready"
116
- #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
117
- case element
118
- when 'link'
119
- target = @browser.link(how.to_sym, what)
120
- when 'button'
121
- target = @browser.button(how.to_sym, what)
122
- else
123
- target = @browser.element(how.to_sym, what)
124
- end
125
- if target.respond_to?("click")
126
- if $watir_script
127
- target.click
128
- else
129
- target.fire_event('onclick')
130
- end
131
- else
132
- fail("#{element} with #{how} '#{what}' does not respond to 'click'")
133
- end
134
- end
135
-
136
- And /^I enter "(.*?)" in text field with "?(.*?)"? "(.*?)"$/ do |value, how, what|
137
- what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
138
- #step "I wait until text field with #{how} \"#{what}\" is ready"
139
- @browser.text_field(how.to_sym, /#{what}/).set(value)
140
- end
141
-
142
- And /^I enter the value for "(.*?)" in text field with "?(.*?)"? "(.*?)"$/ do |index, how, what|
143
- if index =~ /zipcode/
144
- value = @var[index].to_i.to_s
145
- else
146
- value = @var[index]
147
- end
148
- step "I enter \"#{value}\" in text field with #{how} \"#{what}\""
149
- end
150
-
151
- And /^I select the value "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |value, how, what|
152
- #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
153
- @browser.select_list(how.to_sym, what).select_value(/#{value}/)
154
- end
155
-
156
- And /^I select the option "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |option, how, what|
157
- #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
158
- @browser.select_list(how.to_sym, what).select(/#{option}/)
159
- end
160
-
161
- And /^I select the value for "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |index, how, what|
162
- value = @var[index]
163
- step "I select the value \"#{value}\" in select list with #{how} \"#{what}\""
164
- end
165
-
166
- Then /^I check that the "?(.*?)"? with "?(.*?)"? "(.*?)" contains "(.*?)"$/ do |element, how, what, target|
167
- #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
168
- step "I wait until #{element} with #{how} \"#{what}\" is ready"
169
- unless @browser.element(how.to_sym, what).text.include?(target)
170
- fail ("#{element} with #{how} '#{what}' does not contain '#{target}'")
171
- end
172
-
173
- end
174
-
175
- Then /^I check that the text field with "?(.*?)"? "(.*?)" contains the value for "(.*?)"$/ do |how, what, index|
176
- if index =~ /zipcode/
177
- value = @var[index].to_i.to_s
178
- else
179
- value = @var[index]
180
- end
181
- #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
182
- unless @browser.text_field(how.to_sym, what).value.include?(value)
183
- fail("The text field with #{how} '#{what}' does not contain the value for '${index}' ('#{value}'")
184
- end
185
- end
186
-
187
- Then /^I should see "(.*?)"$/ do |text|
188
- step "I wait 1 second"
189
- unless @browser.text.include? text
190
- fail("Did not find text #{text}")
191
- end
192
- end
193
-
194
- Then /^I should not see "(.*?)"$/ do |text|
195
- if @browser.text.include? text
196
- fail("Found text #{text}")
197
- end
198
- end
199
-
200
- Then /^I fill in "(.*?)" with "(.*?)"$/ do |field, value| # assumes a label element and its associated element has id
201
- associated_label = @browser.label(:text, field).attribute_value("for")
202
- #associated_label = @browser.element(:xpath, '//label[contains(text(),"#{arg1}")]').attribute_value("for"))
203
- @browser.text_field(:id, associated_label).set value
204
- end
205
-
206
- Then /^let me debug$|^pry$|^execute binding.pry$/ do
207
- binding.pry
208
- end
209
-
210
- When /^I wait (\d+) seconds?$/ do |seconds|
211
- sleep seconds.to_i
212
- end
213
-
214
- When /^I wait until "?(.*?)"? with "?(.*?)"? "(.*?)" is ready$/ do |element, how, what|
215
- #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
216
- ok = false
217
- if $watir_script
218
- if Watir::Wait.until {@browser.element(how, what).exists?}
219
- if Watir::Wait.until {@browser.element(how, what).visible?}
220
- if Watir::Wait.until {@browser.element(how, what).enabled?}
221
- ok = true
222
- end
223
- end
224
- end
225
- else
226
- case element
227
- when 'button'
228
- if @browser.button(how.to_sym, what).wait_until_present
229
- ok = true
230
- end
231
- when 'text field'
232
- sleep 2
233
- #if @browser.text_field(how.to_sym, what).wait_until_present
234
- ok = true
235
- #end
236
- else
237
- if @browser.element(how.to_sym, what).wait_until_present
238
- ok = true
239
- end
240
- end
241
- end
242
- unless ok
243
- fail("#{element} with #{how} '#{what}' is not ready")
244
- end
245
- end
246
-
247
- And /^I click "(.*?)" in the browser alert$/ do |button|
248
- if $watir_script
249
- $ai.WinWait("Message from webpage")
250
- sleep(1)
251
- $ai.ControlClick("Message from webpage", "", button)
252
- else
253
- @browser.alert.wait_until_present
254
- case button
255
- when /ok/i, /yes/i, /submit/i
256
- @browser.alert.ok
257
- when /cancel/i, /close/i
258
- @browser.alert.close
259
- else
260
- fail("'#{button} for alert not recognized.")
261
- end
262
- end
263
- end
264
-
265
- And /^I close the browser$/ do
266
- @browser.close
267
- end
268
-
269
- Given /^I load data spreadsheet "(.*?)" for "(.*?)"$/ do |file, feature|
270
- require 'roo'
271
- @workbook = Excel.new(file)
272
- @feature_name = feature #File.basename(feature, ".feature")
273
- step "I load @login from spreadsheet"
274
- step "I load @var from spreadsheet"
275
- end
276
-
277
- Then /^I load @login from spreadsheet$/ do
278
- @login = Hash.new
279
- @workbook.default_sheet = @workbook.sheets[0]
280
-
281
- script_col = 0
282
- role_col = 0
283
- userid_col = 0
284
- password_col = 0
285
- url_col = 0
286
- name_col = 0
287
-
288
- 1.upto(@workbook.last_column) do |col|
289
- header = @workbook.cell(1, col)
290
- case header
291
- when @feature_name
292
- script_col = col
293
- when 'role'
294
- role_col = col
295
- when 'userid'
296
- userid_col = col
297
- when 'password'
298
- password_col = col
299
- when 'url'
300
- url_col = col
301
- when 'name'
302
- name_col = col
303
- end
304
- end
305
-
306
- 2.upto(@workbook.last_row) do |line|
307
- role = @workbook.cell(line, role_col)
308
- userid = @workbook.cell(line, userid_col)
309
- password = @workbook.cell(line, password_col)
310
- url = @workbook.cell(line, url_col)
311
- username = @workbook.cell(line, name_col)
312
- enabled = @workbook.cell(line, script_col).to_s
313
-
314
- if enabled == 'Y'
315
- @login['role'] = role
316
- @login['userid'] = userid
317
- @login['password'] = password
318
- @login['url'] = url
319
- @login['name'] = username
320
- @login['enabled'] = enabled
321
- break
322
- end
323
- end
324
- end
325
-
326
- Then /^I load @var from spreadsheet$/ do
327
- @var = Hash.new
328
- @workbook.default_sheet = @workbook.sheets[1]
329
- script_col = 0
330
- name_col = 0
331
-
332
- 1.upto(@workbook.last_column) do |col|
333
- header = @workbook.cell(1, col)
334
- case header
335
- when @feature_name
336
- script_col = col
337
- when 'Variable'
338
- name_col = col
339
- end
340
- end
341
-
342
- 2.upto(@workbook.last_row) do |line|
343
- name = @workbook.cell(line, name_col)
344
- value = @workbook.cell(line, script_col).to_s.strip
345
- @var[name] = value
346
- end
347
- end
348
-
349
- #Before do
350
- # unless awetestlib?
351
- # manifest_file = File.join(File.dirname(__FILE__), '..', 'manifest.json')
352
- # @params = JSON.parse(File.open(manifest_file).read)['params'] #Have access to all params in manifest file
353
- # end
354
- #end
1
+ require 'pry'
2
+
3
+ def awetestlib?
4
+ not Awetestlib::Runner.nil?
5
+ rescue
6
+ return false
7
+ end
8
+
9
+ Given /^I run with Watir$/ do
10
+ require 'watir'
11
+ require 'win32ole'
12
+ $ai = ::WIN32OLE.new('AutoItX3.Control')
13
+ $first_index = 1
14
+ $timestamp = Time.now.strftime("%Y%m%d%H%M%S")
15
+ $watir_script = true
16
+ Watir::IE.close_all
17
+ Watir::IE.visible = true
18
+ end
19
+
20
+ Given /^I run with Classic Watir$/ do
21
+ step "I run with Watir"
22
+ end
23
+
24
+ Given /^I run with Watir-webdriver$/i do
25
+ require 'watir-webdriver'
26
+ $first_index = 0
27
+ $timestamp = Time.now.strftime("%Y%m%d%H%M%S")
28
+ $watir_script = false
29
+ end
30
+
31
+
32
+ When /^I open a new browser$/i do
33
+ if @params
34
+ puts "@params: #{@params}"
35
+ case @params["browser"]
36
+ when "FF"
37
+ step "I open Firefox"
38
+ when "IE"
39
+ step "I open Internet Explorer"
40
+ when "C", "GC"
41
+ step "I open Chrome"
42
+ end
43
+ else
44
+ step "I open Firefox"
45
+ end
46
+ end
47
+
48
+ Given /^I open a F?f?irefox B?b?rowser$/i do
49
+ step "I open Firefox"
50
+ end
51
+
52
+ Given /^I open Firefox$/ do
53
+ step "I run with Watir-webdriver"
54
+ @browser = Watir::Browser.new :firefox
55
+ end
56
+
57
+ Given /^I open a C?c?hrome B?b?rowser$/i do
58
+ step "I open Chrome"
59
+ end
60
+
61
+ Given /^I open Chrome$/ do
62
+ step "I run with Watir-webdriver"
63
+ @browser = Watir::Browser.new :chrome
64
+ end
65
+
66
+ When /^I open an IE B?b?rowser$/i do
67
+ step "I open Internet Explorer"
68
+ end
69
+
70
+ Given /^I open an I?i?nternet E?e?xplorer B?b?rowser$/i do
71
+ step "I open Internet Explorer"
72
+ end
73
+
74
+ Given /^I open Internet Explorer$/i do
75
+ if $watir_script
76
+ step "I run with Watir"
77
+ @browser = Watir::IE.new
78
+ @browser.speed = :fast
79
+ else
80
+ step "I run with Watir-webdriver"
81
+ client = Selenium::WebDriver::Remote::Http::Default.new
82
+ client.timeout = 300 # seconds – default is 60
83
+ @browser = Watir::Browser.new :ie, :http_client => client
84
+ end
85
+ end
86
+
87
+ Then /^I navigate to the environment url$/ do
88
+ if @params and @params['environment'] and @params['environment']['url']
89
+ url = @params['environment']['url']
90
+ elsif @login and @login['url']
91
+ url = @login['url']
92
+ elsif @role and @login[@role] and @login[@role]['url']
93
+ url = @login[@role]['url']
94
+ end
95
+ @browser.goto url
96
+ end
97
+
98
+ Then /^I go to the url "(.*?)"$/ do |url|
99
+ @browser.goto url
100
+ end
101
+
102
+ Then /^I go to the (URL|url)$/ do |dummy|
103
+ step "I navigate to the environment url"
104
+ end
105
+
106
+ Then /^I click "(.*?)"$/ do |element_text|
107
+ step "I click the element with \"text\" \"#{element_text}\""
108
+ end
109
+
110
+ Then /^I click the button "(.*?)"$/ do |element_text|
111
+ step "I click the button with \"text\" \"#{element_text}\""
112
+ end
113
+
114
+ Then /^I click the "?(.*?)"? with "(.*?)" "(.*?)"$/ do |element, how, what|
115
+ step "I wait until #{element} with #{how} \"#{what}\" is ready"
116
+ #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
117
+ case element
118
+ when 'link'
119
+ target = @browser.link(how.to_sym, what)
120
+ when 'button'
121
+ target = @browser.button(how.to_sym, what)
122
+ else
123
+ target = @browser.element(how.to_sym, what)
124
+ end
125
+ if target.respond_to?("click")
126
+ if $watir_script
127
+ target.click
128
+ else
129
+ target.fire_event('onclick')
130
+ end
131
+ else
132
+ fail("#{element} with #{how} '#{what}' does not respond to 'click'")
133
+ end
134
+ end
135
+
136
+ And /^I enter "(.*?)" in text field with "?(.*?)"? "(.*?)"$/ do |value, how, what|
137
+ what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
138
+ #step "I wait until text field with #{how} \"#{what}\" is ready"
139
+ @browser.text_field(how.to_sym, /#{what}/).set(value)
140
+ end
141
+
142
+ And /^I enter the value for "(.*?)" in text field with "?(.*?)"? "(.*?)"$/ do |index, how, what|
143
+ if index =~ /zipcode/
144
+ value = @var[index].to_i.to_s
145
+ else
146
+ value = @var[index]
147
+ end
148
+ step "I enter \"#{value}\" in text field with #{how} \"#{what}\""
149
+ end
150
+
151
+ And /^I select the value "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |value, how, what|
152
+ #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
153
+ @browser.select_list(how.to_sym, what).select_value(/#{value}/)
154
+ end
155
+
156
+ And /^I select the option "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |option, how, what|
157
+ #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
158
+ @browser.select_list(how.to_sym, what).select(/#{option}/)
159
+ end
160
+
161
+ And /^I select the value for "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |index, how, what|
162
+ value = @var[index]
163
+ step "I select the value \"#{value}\" in select list with #{how} \"#{what}\""
164
+ end
165
+
166
+ Then /^I check that the "?(.*?)"? with "?(.*?)"? "(.*?)" contains "(.*?)"$/ do |element, how, what, target|
167
+ #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
168
+ step "I wait until #{element} with #{how} \"#{what}\" is ready"
169
+ unless @browser.element(how.to_sym, what).text.include?(target)
170
+ fail ("#{element} with #{how} '#{what}' does not contain '#{target}'")
171
+ end
172
+
173
+ end
174
+
175
+ Then /^I check that the text field with "?(.*?)"? "(.*?)" contains the value for "(.*?)"$/ do |how, what, index|
176
+ if index =~ /zipcode/
177
+ value = @var[index].to_i.to_s
178
+ else
179
+ value = @var[index]
180
+ end
181
+ #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
182
+ unless @browser.text_field(how.to_sym, what).value.include?(value)
183
+ fail("The text field with #{how} '#{what}' does not contain the value for '${index}' ('#{value}'")
184
+ end
185
+ end
186
+
187
+ Then /^I should see "(.*?)"$/ do |text|
188
+ step "I wait 1 second"
189
+ unless @browser.text.include? text
190
+ fail("Did not find text #{text}")
191
+ end
192
+ end
193
+
194
+ Then /^I should not see "(.*?)"$/ do |text|
195
+ if @browser.text.include? text
196
+ fail("Found text #{text}")
197
+ end
198
+ end
199
+
200
+ Then /^I fill in "(.*?)" with "(.*?)"$/ do |field, value| # assumes a label element and its associated element has id
201
+ associated_label = @browser.label(:text, field).attribute_value("for")
202
+ #associated_label = @browser.element(:xpath, '//label[contains(text(),"#{arg1}")]').attribute_value("for"))
203
+ @browser.text_field(:id, associated_label).set value
204
+ end
205
+
206
+ Then /^let me debug$|^pry$|^execute binding.pry$/ do
207
+ binding.pry
208
+ end
209
+
210
+ When /^I wait (\d+) seconds?$/ do |seconds|
211
+ sleep seconds.to_i
212
+ end
213
+
214
+ When /^I wait until "?(.*?)"? with "?(.*?)"? "(.*?)" is ready$/ do |element, how, what|
215
+ #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
216
+ ok = false
217
+ if $watir_script
218
+ if Watir::Wait.until {@browser.element(how, what).exists?}
219
+ if Watir::Wait.until {@browser.element(how, what).visible?}
220
+ if Watir::Wait.until {@browser.element(how, what).enabled?}
221
+ ok = true
222
+ end
223
+ end
224
+ end
225
+ else
226
+ case element
227
+ when 'button'
228
+ if @browser.button(how.to_sym, what).wait_until_present
229
+ ok = true
230
+ end
231
+ when 'text field'
232
+ sleep 2
233
+ #if @browser.text_field(how.to_sym, what).wait_until_present
234
+ ok = true
235
+ #end
236
+ else
237
+ if @browser.element(how.to_sym, what).wait_until_present
238
+ ok = true
239
+ end
240
+ end
241
+ end
242
+ unless ok
243
+ fail("#{element} with #{how} '#{what}' is not ready")
244
+ end
245
+ end
246
+
247
+ And /^I click "(.*?)" in the browser alert$/ do |button|
248
+ if $watir_script
249
+ $ai.WinWait("Message from webpage")
250
+ sleep(1)
251
+ $ai.ControlClick("Message from webpage", "", button)
252
+ else
253
+ @browser.alert.wait_until_present
254
+ case button
255
+ when /ok/i, /yes/i, /submit/i
256
+ @browser.alert.ok
257
+ when /cancel/i, /close/i
258
+ @browser.alert.close
259
+ else
260
+ fail("'#{button} for alert not recognized.")
261
+ end
262
+ end
263
+ end
264
+
265
+ And /^I close the browser$/ do
266
+ @browser.close
267
+ end
268
+
269
+ Given /^I load data spreadsheet "(.*?)" for "(.*?)"$/ do |file, feature|
270
+ require 'roo'
271
+ @workbook = Excel.new(file)
272
+ @feature_name = feature #File.basename(feature, ".feature")
273
+ step "I load @login from spreadsheet"
274
+ step "I load @var from spreadsheet"
275
+ end
276
+
277
+ Then /^I load @login from spreadsheet$/ do
278
+ @login = Hash.new
279
+ @workbook.default_sheet = @workbook.sheets[0]
280
+
281
+ script_col = 0
282
+ role_col = 0
283
+ userid_col = 0
284
+ password_col = 0
285
+ url_col = 0
286
+ name_col = 0
287
+
288
+ 1.upto(@workbook.last_column) do |col|
289
+ header = @workbook.cell(1, col)
290
+ case header
291
+ when @feature_name
292
+ script_col = col
293
+ when 'role'
294
+ role_col = col
295
+ when 'userid'
296
+ userid_col = col
297
+ when 'password'
298
+ password_col = col
299
+ when 'url'
300
+ url_col = col
301
+ when 'name'
302
+ name_col = col
303
+ end
304
+ end
305
+
306
+ 2.upto(@workbook.last_row) do |line|
307
+ role = @workbook.cell(line, role_col)
308
+ userid = @workbook.cell(line, userid_col)
309
+ password = @workbook.cell(line, password_col)
310
+ url = @workbook.cell(line, url_col)
311
+ username = @workbook.cell(line, name_col)
312
+ enabled = @workbook.cell(line, script_col).to_s
313
+
314
+ if enabled == 'Y'
315
+ @login['role'] = role
316
+ @login['userid'] = userid
317
+ @login['password'] = password
318
+ @login['url'] = url
319
+ @login['name'] = username
320
+ @login['enabled'] = enabled
321
+ break
322
+ end
323
+ end
324
+ end
325
+
326
+ Then /^I load @var from spreadsheet$/ do
327
+ @var = Hash.new
328
+ @workbook.default_sheet = @workbook.sheets[1]
329
+ script_col = 0
330
+ name_col = 0
331
+
332
+ 1.upto(@workbook.last_column) do |col|
333
+ header = @workbook.cell(1, col)
334
+ case header
335
+ when @feature_name
336
+ script_col = col
337
+ when 'Variable'
338
+ name_col = col
339
+ end
340
+ end
341
+
342
+ 2.upto(@workbook.last_row) do |line|
343
+ name = @workbook.cell(line, name_col)
344
+ value = @workbook.cell(line, script_col).to_s.strip
345
+ @var[name] = value
346
+ end
347
+ end
348
+
349
+ #Before do
350
+ # unless awetestlib?
351
+ # manifest_file = File.join(File.dirname(__FILE__), '..', 'manifest.json')
352
+ # @params = JSON.parse(File.open(manifest_file).read)['params'] #Have access to all params in manifest file
353
+ # end
354
+ #end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awetestlib
3
3
  version: !ruby/object:Gem::Version
4
- hash: -223651765
4
+ hash: -223651763
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
9
  - 30
10
10
  - pre
11
- - 1
12
- version: 0.1.30pre1
11
+ - 2
12
+ version: 0.1.30pre2
13
13
  platform: x86-mingw32
14
14
  authors:
15
15
  - Anthony Woo
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2013-05-02 00:00:00 Z
21
+ date: 2013-05-03 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: watir-webdriver