awetestlib 0.1.30pre3 → 0.1.30
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/README.md +74 -33
- data/lib/awetestlib/html_report.rb +15 -0
- data/lib/version.rb +2 -2
- data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +46 -39
- metadata +4 -7
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,62 +1,90 @@
|
|
1
1
|
Awetestlib
|
2
2
|
==========
|
3
3
|
|
4
|
-
|
4
|
+
Automate testing of browser-based applications in Windows or Mac.
|
5
5
|
|
6
6
|
After completing this guide you will be able to run tests locally from command line or from an IDE.
|
7
7
|
|
8
8
|
------------
|
9
|
+
## Prerequisites: Ruby 1.8.7 and RubyInstaller Devkit
|
9
10
|
|
10
|
-
|
11
|
+
You need to have Ruby 1.8.7 installed using RubyInstaller.
|
11
12
|
|
12
|
-
You
|
13
|
-
[here](http://rubyinstaller.org/downloads/)
|
13
|
+
You can download the RubyInstaller for 1.8.7
|
14
|
+
[here](http://rubyinstaller.org/downloads/). Choose the most recent 1.8.7.
|
15
|
+
|
16
|
+
Make sure you tell the installer to put Ruby in the PATH environment variable.
|
14
17
|
|
15
18
|
You can check your Ruby version using:
|
16
19
|
|
17
20
|
ruby -v
|
18
21
|
|
19
|
-
Additionally, for Windows, you will need to install the RubyInstaller DevKit to compile a few dependent gems.
|
22
|
+
Additionally, for Windows, you will need to install the RubyInstaller DevKit to compile a few dependent gems.
|
23
|
+
|
24
|
+
Download DevKit
|
20
25
|
[here](http://rubyinstaller.org/downloads/)
|
21
26
|
and the installation directions can be found
|
22
|
-
[here](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit)
|
27
|
+
[here](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit).
|
23
28
|
|
24
|
-
|
29
|
+
Choose the one for Ruby 1.8.7.
|
25
30
|
|
26
|
-
|
31
|
+
If you have difficulties with the above in Windows 7 and/or behind a firewall, you may have to set the http_proxy and/or run the installers as administrator. (see below)
|
27
32
|
|
28
|
-
|
33
|
+
## Install Awetestlib
|
29
34
|
|
30
|
-
|
35
|
+
**Start** by opening a command window or terminal
|
36
|
+
|
37
|
+
----------
|
38
|
+
|
39
|
+
####NOTE: If you are behind a firewall:
|
40
|
+
|
41
|
+
1. You will need to set the http_proxy environment variable
|
42
|
+
2. You may have to change the HOMEDRIVE environment variable to C: in Windows
|
43
|
+
3. You may need to run the Windows 7 command window as administrator.
|
44
|
+
|
45
|
+
In Windows
|
46
|
+
|
47
|
+
set http_proxy=http://myproxy.mycompany.com:80
|
48
|
+
set HOMEDRIVE=C:
|
49
|
+
|
50
|
+
In OSX
|
51
|
+
|
52
|
+
export HTTP_PROXY=http://myproxy.mycompany.com:80
|
53
|
+
|
54
|
+
|
55
|
+
----------
|
56
|
+
|
31
57
|
|
58
|
+
**Then**, in a terminal or command prompt, install the awetestlib gem:
|
32
59
|
|
33
|
-
|
60
|
+
gem install awetestlib --no-ri --no-rdoc
|
61
|
+
|
62
|
+
Note: This could take up to 5 minutes for first time installs. You may need to use 'sudo' on OSX
|
34
63
|
|
35
|
-
|
64
|
+
**Then** run the following command and verify the step
|
36
65
|
|
37
66
|
awetestlib regression_setup
|
38
67
|
|
39
|
-
|
68
|
+
### Usage
|
40
69
|
|
41
70
|
Run the following command to see the different usages
|
42
71
|
|
43
72
|
awetestlib
|
44
73
|
|
45
74
|
## Setup Browsers
|
46
|
-
|
47
|
-
### Setup Safari (Mac OS X only)
|
48
|
-
|
75
|
+
### Safari (Mac OS X only)
|
49
76
|
To setup support for Safari browser, please follow the instructions at [SafariDriver](http://code.google.com/p/selenium/wiki/SafariDriver)
|
50
77
|
|
51
|
-
It is
|
78
|
+
It is likely you will need to start a selenium-server-standalone process in a terminal session before running Safari scripts, else you will get a 'waiting for connection' error. Get the jar [here](https://code.google.com/p/selenium/downloads/list).
|
79
|
+
|
52
80
|
When using raw Watir-webdriver for Safari, open the browser with
|
53
81
|
|
54
82
|
browser = Watir::Browser.new(:remote, :desired_capabilities=>:'safari')
|
55
83
|
|
56
|
-
###
|
84
|
+
### Chrome
|
57
85
|
To setup support for Google Chrome browser, please download the latest Chromedriver version from [here](http://code.google.com/p/chromedriver/downloads/list)
|
58
86
|
|
59
|
-
Then move the executables in your PATH. To find your
|
87
|
+
Then move the executables in your PATH. To find your PATH, type the command below in your terminal/command prompt:
|
60
88
|
|
61
89
|
For Mac OSX:
|
62
90
|
|
@@ -65,13 +93,15 @@ For Mac OSX:
|
|
65
93
|
For Windows:
|
66
94
|
|
67
95
|
PATH
|
68
|
-
|
69
|
-
|
70
|
-
|
96
|
+
|
97
|
+
We suggest putting both drivers in \Ruby187\bin as it should already be in your path.
|
98
|
+
|
99
|
+
### Internet Explorer
|
100
|
+
To setup support for Internet Explorer, please download the latest IEDriverServer version from [here](http://code.google.com/p/selenium/downloads/list)
|
71
101
|
and move the executable into your PATH.
|
72
102
|
|
73
103
|
|
74
|
-
|
104
|
+
## Setup IDEs (Rubymine, Netbeans)
|
75
105
|
|
76
106
|
To setup the awetestlib gem with Rubymine use:
|
77
107
|
|
@@ -81,7 +111,7 @@ To setup awetestlib with Netbeans use:
|
|
81
111
|
|
82
112
|
awetestlib netbeans_setup <ProjectName>
|
83
113
|
|
84
|
-
You can now start your scripts within the IDE.
|
114
|
+
You can now start your scripts within the IDE. Follow the instructions in each IDE for creating and executing run/debug configurations.
|
85
115
|
|
86
116
|
For additional information on IDE setup, refer to the links below:
|
87
117
|
|
@@ -89,17 +119,20 @@ For additional information on IDE setup, refer to the links below:
|
|
89
119
|
|
90
120
|
- [Rubymine IDE setup](https://github.com/3qilabs/awetestlib/blob/develop/rubymine_setup.md)
|
91
121
|
|
92
|
-
|
93
|
-
|
122
|
+
## Command Line Execution
|
123
|
+
If you prefer to run your tests from command line, you can use the following command
|
124
|
+
|
125
|
+
`awetestlib <script_file> [parameters]`
|
126
|
+
|
127
|
+
For example: To run a script named demo.rb in Firefox, your command will look like:
|
94
128
|
|
95
|
-
|
96
|
-
- `awetestlib demo.rb -b FF`
|
129
|
+
`awetestlib demo.rb -b FF`
|
97
130
|
|
98
|
-
|
131
|
+
Here is the full list of the currently available command line parameters:
|
99
132
|
|
100
|
-
Usage: awetestlib <script_file> [parameters]
|
133
|
+
Usage: awetestlib <script_file> [parameters]
|
101
134
|
-b, --browser BROWSER Specify a browser (IE, FF, S, C)
|
102
|
-
-r, --root_path ROOT_PATH Specify the root path
|
135
|
+
-r, --root_path ROOT_PATH Specify the root path (default is current path)
|
103
136
|
-l, --library LIBRARY Specify a library to be loaded
|
104
137
|
-x, --excel EXCEL_FILE Specify an excel file containing variables to be loaded
|
105
138
|
-v, --version VERSION Specify a browser version
|
@@ -110,13 +143,21 @@ The full list of parameters for the command line currently are:
|
|
110
143
|
-s, --screencap_path PATH Specify the path where screenshots will be saved
|
111
144
|
-o, --output_to_log Write to log file
|
112
145
|
--log_path_subdir SUBDIR Specify log path relative to root_path
|
146
|
+
-p, --pry Require Pry for debugging
|
147
|
+
-c, --classic_watir Use Classic Watir for IE instead of Watir-webdriver
|
113
148
|
--report_all_test_refs Include list of all error/test case reference ids actually validated
|
114
149
|
|
115
|
-
To start writing your own script, refer to the [Scripting Guide/Wiki](https://github.com/3qilabs/awetestlib/wiki/Getting-Started---Scripting) wiki
|
150
|
+
To start writing your own script, refer to the [Scripting Guide/Wiki](https://github.com/3qilabs/awetestlib/wiki/Getting-Started---Scripting) wiki.
|
151
|
+
|
152
|
+
For the latest documentation of the Awetest DSL go to [Rubydoc](http://rubydoc.info/gems/awetestlib) and look in Awetestlib::Regression.
|
116
153
|
|
117
154
|
### Cucumber Support
|
118
155
|
|
119
|
-
One of the technologies that the Awetest framework supports is [Cucumber](http://cukes.info/). To get setup with cucumber, you can run the following command:
|
156
|
+
One of the technologies that the Awetest framework supports is [Cucumber](http://cukes.info/). To get setup with cucumber, you can run the following command:
|
157
|
+
|
158
|
+
`awetestlib cucumber_setup <ProjectName>`
|
159
|
+
|
160
|
+
That will create the standard cucumber folder structure in the ProjectName directory.
|
120
161
|
|
121
162
|
Visit our [wiki](https://github.com/3qilabs/awetestlib/wiki/Predefined-Cucumber-Web-Steps) to see the list of predefined steps provided by awetestlib
|
122
163
|
|
@@ -147,6 +147,21 @@ module Awetestlib
|
|
147
147
|
|
148
148
|
@reportContent2 += row + "\n"
|
149
149
|
|
150
|
+
|
151
|
+
#if (result == 'PASSED')
|
152
|
+
# @reportContent2 = @reportContent2 + '<tr>C'
|
153
|
+
# @reportContent2 = @reportContent2 + '<td class=border_right width=20%><p class=result_ok>' + result + '</p></td>'
|
154
|
+
#elsif (result == 'FAILED')
|
155
|
+
# @reportContent2 = @reportContent2 + '<tr><td class=border_left width=80%><p class=normal_text>' + step + '</p></td>'
|
156
|
+
# @reportContent2 = @reportContent2 + '<td class=border_right width=20%><p class=result_nok>' + result + '</p></td>'
|
157
|
+
#elsif level < 1
|
158
|
+
# @reportContent2 = @reportContent2 + '<tr><td class=border_left width=80%><p class=normal_text>' + step + '</p></td>'
|
159
|
+
# @reportContent2 = @reportContent2 + '<td class=border_right width=20%><p class=result_ok>' + result + '</p></td>'
|
160
|
+
#else
|
161
|
+
# @reportContent2 = @reportContent2 + '<tr><td class=mark_testlevel_left width=80%><p class=bold_large_text>' + step + '</p></td>'
|
162
|
+
# @reportContent2 = @reportContent2 + '<td class=mark_testlevel_right width=20%><p class=result_ok>' + result + '</p></td>'
|
163
|
+
#end
|
164
|
+
|
150
165
|
end
|
151
166
|
|
152
167
|
# Close the report HTML
|
data/lib/version.rb
CHANGED
@@ -5,20 +5,20 @@ rescue
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def setup_classic_watir
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
require 'watir'
|
9
|
+
require 'win32ole'
|
10
|
+
$ai = ::WIN32OLE.new('AutoItX3.Control')
|
11
|
+
$first_index = 1
|
12
|
+
$timestamp = Time.now.strftime("%Y%m%d%H%M%S")
|
13
|
+
$watir_script = true
|
14
|
+
Watir::IE.close_all
|
15
|
+
Watir::IE.visible = true
|
16
|
+
end
|
17
17
|
|
18
18
|
def setup_watir_webdriver
|
19
19
|
require 'watir-webdriver'
|
20
|
-
$first_index
|
21
|
-
$timestamp
|
20
|
+
$first_index = 0
|
21
|
+
$timestamp = Time.now.strftime("%Y%m%d%H%M%S")
|
22
22
|
$watir_script = false
|
23
23
|
end
|
24
24
|
|
@@ -27,6 +27,11 @@ def open_firefox
|
|
27
27
|
@browser = Watir::Browser.new :firefox
|
28
28
|
end
|
29
29
|
|
30
|
+
def open_safari
|
31
|
+
setup_watir_webdriver
|
32
|
+
@browser = Watir::Browser.new(:remote, :desired_capabilities => :'safari')
|
33
|
+
end
|
34
|
+
|
30
35
|
def open_chrome
|
31
36
|
setup_watir_webdriver
|
32
37
|
@browser = Watir::Browser.new :chrome
|
@@ -47,7 +52,7 @@ end
|
|
47
52
|
|
48
53
|
def navigate_to_environment_url
|
49
54
|
if @params and @params['environment'] and @params['environment']['url']
|
50
|
-
|
55
|
+
url = @params['environment']['url']
|
51
56
|
elsif @login and @login['url']
|
52
57
|
url = @login['url']
|
53
58
|
elsif @role and @login[@role] and @login[@role]['url']
|
@@ -58,22 +63,24 @@ end
|
|
58
63
|
|
59
64
|
def open_a_browser
|
60
65
|
if @params
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
66
|
+
puts "@params: #{@params}"
|
67
|
+
case @params["browser"]
|
68
|
+
when "FF"
|
69
|
+
open_firefox
|
70
|
+
when "IE"
|
71
|
+
open_internet_explorer
|
72
|
+
when "C", "GC"
|
73
|
+
open_chrome
|
74
|
+
when "S"
|
75
|
+
open_safari
|
76
|
+
end
|
77
|
+
else
|
78
|
+
if $watir_script
|
79
|
+
open_internet_explorer
|
80
|
+
else
|
81
|
+
open_firefox
|
82
|
+
end
|
83
|
+
end
|
77
84
|
end
|
78
85
|
|
79
86
|
Given /^I run with Watir$/ do
|
@@ -253,9 +260,9 @@ When /^I wait until "?(.*?)"? with "?(.*?)"? "(.*?)" is ready$/ do |element, how
|
|
253
260
|
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
254
261
|
ok = false
|
255
262
|
if $watir_script
|
256
|
-
if Watir::Wait.until {@browser.element(how, what).exists?}
|
257
|
-
if Watir::Wait.until {@browser.element(how, what).visible?}
|
258
|
-
if Watir::Wait.until {@browser.element(how, what).enabled?}
|
263
|
+
if Watir::Wait.until { @browser.element(how, what).exists? }
|
264
|
+
if Watir::Wait.until { @browser.element(how, what).visible? }
|
265
|
+
if Watir::Wait.until { @browser.element(how, what).enabled? }
|
259
266
|
ok = true
|
260
267
|
end
|
261
268
|
end
|
@@ -269,8 +276,8 @@ When /^I wait until "?(.*?)"? with "?(.*?)"? "(.*?)" is ready$/ do |element, how
|
|
269
276
|
when 'text field'
|
270
277
|
sleep 2
|
271
278
|
#if @browser.text_field(how.to_sym, what).wait_until_present
|
272
|
-
|
273
|
-
|
279
|
+
ok = true
|
280
|
+
#end
|
274
281
|
else
|
275
282
|
if @browser.element(how.to_sym, what).wait_until_present
|
276
283
|
ok = true
|
@@ -306,14 +313,14 @@ end
|
|
306
313
|
|
307
314
|
Given /^I load data spreadsheet "(.*?)" for "(.*?)"$/ do |file, feature|
|
308
315
|
require 'roo'
|
309
|
-
@workbook
|
310
|
-
@feature_name
|
316
|
+
@workbook = Excel.new(file)
|
317
|
+
@feature_name = feature #File.basename(feature, ".feature")
|
311
318
|
step "I load @login from spreadsheet"
|
312
319
|
step "I load @var from spreadsheet"
|
313
320
|
end
|
314
321
|
|
315
322
|
Then /^I load @login from spreadsheet$/ do
|
316
|
-
@login
|
323
|
+
@login = Hash.new
|
317
324
|
@workbook.default_sheet = @workbook.sheets[0]
|
318
325
|
|
319
326
|
script_col = 0
|
@@ -362,10 +369,10 @@ Then /^I load @login from spreadsheet$/ do
|
|
362
369
|
end
|
363
370
|
|
364
371
|
Then /^I load @var from spreadsheet$/ do
|
365
|
-
@var
|
372
|
+
@var = Hash.new
|
366
373
|
@workbook.default_sheet = @workbook.sheets[1]
|
367
|
-
script_col
|
368
|
-
name_col
|
374
|
+
script_col = 0
|
375
|
+
name_col = 0
|
369
376
|
|
370
377
|
1.upto(@workbook.last_column) do |col|
|
371
378
|
header = @workbook.cell(1, col)
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awetestlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 39
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
9
|
- 30
|
10
|
-
|
11
|
-
- 3
|
12
|
-
version: 0.1.30pre3
|
10
|
+
version: 0.1.30
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Anthony Woo
|
@@ -18,7 +16,7 @@ autorequire:
|
|
18
16
|
bindir: bin
|
19
17
|
cert_chain: []
|
20
18
|
|
21
|
-
date: 2013-05-
|
19
|
+
date: 2013-05-21 00:00:00 Z
|
22
20
|
dependencies:
|
23
21
|
- !ruby/object:Gem::Dependency
|
24
22
|
name: watir-webdriver
|
@@ -398,4 +396,3 @@ specification_version: 3
|
|
398
396
|
summary: Awetest DSL for automated testing of browser-based applications.
|
399
397
|
test_files: []
|
400
398
|
|
401
|
-
has_rdoc:
|