watir_helper 0.1.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/README +58 -110
- data/lib/watir_helper.rb +2 -9
- data/lib/watir_helper/browser_helper.rb +42 -30
- data/lib/watir_helper/button_helper.rb +17 -20
- data/lib/watir_helper/checkbox_helper.rb +14 -16
- data/lib/watir_helper/common_helpers.rb +7 -6
- data/lib/watir_helper/data_type_validations.rb +36 -0
- data/lib/watir_helper/div_helper.rb +16 -19
- data/lib/watir_helper/frame_helper.rb +134 -55
- data/lib/watir_helper/image_helper.rb +16 -19
- data/lib/watir_helper/include_other_helpers.rb +44 -0
- data/lib/watir_helper/link_helper.rb +12 -13
- data/lib/watir_helper/login_helper.rb +16 -19
- data/lib/watir_helper/popup_handling_helper.rb +63 -67
- data/lib/watir_helper/radio_button_helper.rb +14 -16
- data/lib/watir_helper/select_list_helper.rb +16 -19
- data/lib/watir_helper/span_helper.rb +8 -7
- data/lib/watir_helper/table_helper.rb +11 -11
- data/lib/watir_helper/textfield_helper.rb +22 -30
- data/lib/watir_helper/validations_helper.rb +106 -101
- data/test/test_watir_helper.rb +17 -0
- metadata +17 -20
- data/lib/watir_helper/include_all_helpers.rb +0 -51
- data/test/testing_watir_helper.rb +0 -37
- data/test/testing_watir_helper_spec.rb +0 -25
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OGJjMmEzZjY4ZGUzNGQ3ODlmNTNiNzE2OTJhMGQzNjZhM2Q2NDJmNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZmQzNzU1YTkyYTkwMGFkZDY5YzQyZDA5ZjQxZDQ0OGI4Y2FkM2NhYg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2U1ZjNlNDZiNGUzNDc3ZTljNDA0YjUwZjFkMTI4Mjc5MTY5NzkwMTA3OWZl
|
10
|
+
ZDE5NWI5ODU1MDE1ODM3M2Y2MmVmNTZjYjYwZDYwZjUyOGYyZGNiNDc0MGZj
|
11
|
+
YTczMzYxOWMzYTM2MDg0NDk1NmU5NzI0YWNiOTNiMzE3MTA0NTk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWU2Y2M5Y2FhMjE1MzZkZjZkMWUxMzlhODMyZTJlMDFlZDBmN2U3NjZhMjlj
|
14
|
+
OTYwMDBhYzU4NGQxMTJmNmY2ZDNhZDRkODJiZjk2MjBlZmQwNTkwNjY1MDUz
|
15
|
+
OWI1MWYxNjAzNDUzODBlYzgyMWY5NjQ3ZGM4NGIzNTkwYjFjZWI=
|
data/README
CHANGED
@@ -1,170 +1,118 @@
|
|
1
|
-
About this
|
1
|
+
About this gem:
|
2
2
|
|
3
|
-
This is
|
3
|
+
This gem is developed for novice automation tester's to write automation scripts
|
4
|
+
fast as it is very easy to use.
|
4
5
|
|
5
6
|
Features:-
|
6
7
|
|
7
|
-
1.
|
8
|
+
1. Freedom to choose the browser. Right now this gem is only tested with IE.
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
# ie = set_browser("ie")
|
11
|
+
|
12
|
+
2. Method name's are simple and easy to remember. For e.g:
|
13
|
+
|
14
|
+
# require 'watir_helper'
|
12
15
|
|
13
|
-
#
|
16
|
+
# ie1 = set_browser("ie")
|
14
17
|
|
15
|
-
#
|
18
|
+
# goto_page(ie1, "http://www.google.com/")
|
19
|
+
|
20
|
+
# close_browser(ie1)
|
16
21
|
|
17
|
-
#
|
22
|
+
# ie2 = set_browser("ie")
|
23
|
+
|
24
|
+
# goto_page(ie2, "http://rubygems.com/")
|
18
25
|
|
19
|
-
# close_browser()
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
4. Pop-up handling is easy using given parameterized functions in this gem.
|
26
|
+
# close_browser(ie2)
|
27
|
+
|
28
|
+
3. Data validations like email-id validation, date format(like mmddyyyy or ddmmyyyy) validation etc.
|
29
|
+
are also incorporated.
|
30
|
+
|
31
|
+
4. For Pop-up handling, you have to just use one line named method's of this gem. It's that easy.
|
26
32
|
|
27
|
-
5. To enable the Pop-up handling, execute the following steps on your command prompt :-
|
28
|
-
|
29
|
-
- cd C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.2\lib\watir
|
30
|
-
|
31
|
-
- regsvr32 AutoItX3.dll
|
32
|
-
|
33
|
-
- You will get a pop-up of successful registration , press "OK" button on it.
|
34
33
|
|
35
|
-
|
34
|
+
# click_ok_js_popup("File Download")
|
36
35
|
|
37
|
-
|
36
|
+
|
37
|
+
# click_save_saveas_popup("Save As", "C://Test_Data")
|
38
38
|
|
39
|
+
|
40
|
+
5. You can add new features into this gem.
|
39
41
|
|
42
|
+
|
40
43
|
Prerequisites:
|
41
44
|
|
42
|
-
Install Ruby:
|
45
|
+
Install Ruby:
|
43
46
|
|
44
|
-
First you need to install Ruby using the one-click installer for Windows
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
First you need to install Ruby using the one-click installer for Windows from
|
48
|
+
http://ruby-lang.org .
|
48
49
|
|
49
50
|
Install Watir:
|
50
51
|
|
51
|
-
Watir is packaged as a gem, a Ruby library that can be installed over the
|
52
|
-
internet.
|
52
|
+
Watir is packaged as a gem, a Ruby library that can be installed over the internet.
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
Note:
|
57
|
-
|
58
|
-
The latest version of Watir is 1.6.5 whose close function doesn't work fine if we handle pop-up's in our scripts.But close function of Watir 1.6.2 works fine with pop-up handling.Watir 1.6.2 was released in November 2009.
|
54
|
+
To install it, type this at command prompt:
|
59
55
|
|
60
|
-
To install it, type this at command prompt:
|
61
|
-
|
62
|
-
gem install watir (for latest version)
|
63
56
|
gem install watir
|
64
|
-
|
65
|
-
-v 1.6.2 (for version 1.6.2)
|
66
|
-
|
67
|
-
Install rspec:
|
68
|
-
|
69
|
-
gem install rspec (This will download the latest version)
|
70
57
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
Install rake:
|
58
|
+
Install rake :
|
76
59
|
|
77
|
-
|
78
|
-
|
60
|
+
gem install rake
|
79
61
|
|
62
|
+
Install IE Developer Toolbar from the site :
|
63
|
+
|
64
|
+
http://www.microsoft.com/en-in/download/details.aspx?id=18359
|
80
65
|
|
81
|
-
|
66
|
+
How To Use:
|
82
67
|
|
83
|
-
|
68
|
+
This only works on Windows. Requires Internet Explorer 5.5 or newer.
|
84
69
|
|
85
|
-
|
86
|
-
To Use:
|
87
|
-
This only works on Windows.Requires Internet Explorer 5.5 or newer.
|
88
|
-
Typical Usage
|
70
|
+
Typical Usage :
|
89
71
|
|
90
|
-
#
|
72
|
+
# Include the gem 'watir_helper'
|
91
73
|
|
92
74
|
require 'watir_helper'
|
75
|
+
|
76
|
+
# Set browser
|
77
|
+
ie = set_browser("ie")
|
78
|
+
|
79
|
+
# Supply Google url to goto_page
|
93
80
|
|
94
|
-
|
95
|
-
|
96
|
-
include WatirHelper
|
97
|
-
|
98
|
-
# Go to the Google home page
|
99
|
-
|
100
|
-
goto_page("http://www.google.com/")
|
81
|
+
goto_page(ie, "http://www.google.com/")
|
101
82
|
|
102
|
-
#
|
83
|
+
# Display title of the current browser page
|
103
84
|
|
104
|
-
puts get_title
|
85
|
+
puts get_title(ie)
|
105
86
|
|
106
|
-
#
|
87
|
+
# Display url of the current browser page
|
107
88
|
|
108
|
-
puts get_url
|
89
|
+
puts get_url(ie)
|
109
90
|
|
110
91
|
# Flash the Google logo on the home page
|
111
92
|
|
112
|
-
flash_image("id","logo")
|
93
|
+
flash_image(ie, "id", "logo")
|
113
94
|
|
114
95
|
# Check whether Google logo image exists or not
|
115
96
|
|
116
|
-
puts exists_image("id","logo")
|
97
|
+
puts exists_image?(ie, "id", "logo")
|
117
98
|
|
118
99
|
# Set the search field to Ruby
|
119
100
|
|
120
|
-
set_textfield("name","q","Ruby")
|
101
|
+
set_textfield(ie, "name", "q", "Ruby")
|
121
102
|
|
122
103
|
# Highlight the Google Search button
|
123
104
|
|
124
|
-
flash_button("value","Google Search")
|
105
|
+
flash_button(ie, "value", "Google Search")
|
125
106
|
|
126
107
|
# Click the Google Search button
|
127
108
|
|
128
|
-
click_button("value","Google Search")
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
Pop Up's Support
|
134
|
-
:-
|
135
|
-
Watir now optionally installs AutoIt - http://www.autoitscript.com/
|
136
|
-
|
137
|
-
This is the prefered method for dealing wth pop ups, file requesters etc.
|
138
|
-
|
139
|
-
To enable the same, execute the following steps on your command prompt :-
|
140
|
-
|
141
|
-
- cd C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.2\lib\watir
|
142
|
-
|
143
|
-
- regsvr32 AutoItX3.dll
|
144
|
-
|
145
|
-
- You will get a pop-up of successful registration , press "OK" button on it.
|
146
|
-
|
147
|
-
Now,You can easily handle pop-up's.
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
Note: The latest version of Watir is 1.6.5 whose close function doesn't work fine if we handle pop-up's in our scripts.But close function of Watir 1.6.2 works fine with pop-up handling.
|
152
|
-
|
153
|
-
|
109
|
+
click_button(ie, "value", "Google Search")
|
154
110
|
|
155
111
|
Contacts:
|
156
112
|
|
157
113
|
The mailing list: http://groups.google.com/group/watir-general
|
158
114
|
|
159
115
|
E-mail :- ankurgera@gmail.com
|
160
|
-
|
161
|
-
|
162
|
-
yashasree.barve@gmail.com
|
163
|
-
|
116
|
+
|
164
117
|
Contributors:
|
165
118
|
Ankur Gera
|
166
|
-
|
167
|
-
Yashasree Barve
|
168
|
-
|
169
|
-
Thanks for your ideas and support
|
170
|
-
.
|
data/lib/watir_helper.rb
CHANGED
@@ -1,9 +1,2 @@
|
|
1
|
-
require 'watir_helper/common_helpers'
|
2
|
-
|
3
|
-
|
4
|
-
module WatirHelper
|
5
|
-
|
6
|
-
require 'watir_helper/include_all_helpers'
|
7
|
-
|
8
|
-
end
|
9
|
-
|
1
|
+
require File.expand_path('watir_helper/common_helpers', File.dirname(__FILE__))
|
2
|
+
require File.expand_path('watir_helper/include_other_helpers', File.dirname(__FILE__))
|
@@ -1,62 +1,74 @@
|
|
1
|
-
|
1
|
+
#******************************************************
|
2
|
+
#Browser methods
|
3
|
+
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
2
5
|
|
3
6
|
module BrowserHelper
|
4
7
|
|
8
|
+
#Set a browser.
|
9
|
+
#For e.g set_browser("ie")
|
10
|
+
def set_browser(browser_name)
|
11
|
+
Watir::Browser.new browser_name.intern
|
12
|
+
end
|
13
|
+
|
5
14
|
#Go to a page.
|
6
|
-
def goto_page(url)
|
7
|
-
|
15
|
+
def goto_page(browser_handle, url)
|
16
|
+
browser_handle.goto(url)
|
8
17
|
end
|
9
18
|
|
10
19
|
#Go to the next page.
|
11
|
-
def goto_next_page()
|
12
|
-
|
20
|
+
def goto_next_page(browser_handle)
|
21
|
+
browser_handle.forward
|
13
22
|
end
|
14
23
|
|
15
24
|
#Go to the previous page.
|
16
|
-
def goto_previous_page()
|
17
|
-
|
25
|
+
def goto_previous_page(browser_handle)
|
26
|
+
browser_handle.back
|
18
27
|
end
|
19
28
|
|
20
29
|
#Refresh the page.
|
21
|
-
def refresh_the_page()
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
#Close the browser.
|
26
|
-
def close_browser()
|
27
|
-
title=get_title()
|
28
|
-
$ai.WinKill(title)
|
30
|
+
def refresh_the_page(browser_handle)
|
31
|
+
browser_handle.refresh
|
29
32
|
end
|
30
33
|
|
31
34
|
#Get the title of the browser.
|
32
|
-
def get_title()
|
33
|
-
|
35
|
+
def get_title(browser_handle)
|
36
|
+
browser_handle.title
|
34
37
|
end
|
35
38
|
|
36
39
|
#Get the url of the browser.
|
37
|
-
def get_url()
|
38
|
-
|
40
|
+
def get_url(browser_handle)
|
41
|
+
browser_handle.url
|
39
42
|
end
|
40
43
|
|
41
|
-
#
|
42
|
-
def
|
43
|
-
|
44
|
-
|
44
|
+
#Close the browser.
|
45
|
+
def close_browser(browser_handle)
|
46
|
+
browser_handle.close
|
47
|
+
end
|
48
|
+
|
49
|
+
#Attach a browser window.
|
50
|
+
def attach_browser(browser_handle, property, property_value)
|
51
|
+
browser_handle.attach(property.intern, /#{property_value}/)
|
52
|
+
end
|
53
|
+
|
54
|
+
#Close attached browser window.
|
55
|
+
def close_attached_browser(browser_handle)
|
56
|
+
close_browser(browser_handle)
|
45
57
|
end
|
46
58
|
|
47
59
|
#Minimize the browser.
|
48
|
-
def minimize_browser()
|
49
|
-
|
60
|
+
def minimize_browser(browser_handle)
|
61
|
+
browser_handle.minimize
|
50
62
|
end
|
51
63
|
|
52
64
|
#Maximize the browser.
|
53
|
-
def maximize_browser()
|
54
|
-
|
65
|
+
def maximize_browser(browser_handle)
|
66
|
+
browser_handle.maximize
|
55
67
|
end
|
56
68
|
|
57
69
|
#Verify whether text is present or not.
|
58
|
-
def verify_text(text)
|
59
|
-
|
70
|
+
def verify_text?(browser_handle, text)
|
71
|
+
browser_handle.text.include?(text)
|
60
72
|
end
|
61
73
|
|
62
|
-
end
|
74
|
+
end
|
@@ -1,41 +1,38 @@
|
|
1
|
-
|
1
|
+
#******************************************************
|
2
|
+
#Button methods
|
3
|
+
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
2
5
|
|
3
6
|
module ButtonHelper
|
4
7
|
|
5
8
|
#Click a button.
|
6
|
-
def click_button(property,
|
7
|
-
|
8
|
-
$ie.button(property.intern,propertyvalue).click
|
9
|
+
def click_button(browser_handle, property, property_value)
|
10
|
+
browser_handle.button(property.intern, /#{property_value}/).click
|
9
11
|
end
|
10
12
|
|
11
13
|
#Click a button ,after clicking which a pop-up will come.
|
12
|
-
def click_button_with_popup(property,
|
13
|
-
|
14
|
-
$ie.button(property.intern,propertyvalue).click_no_wait
|
14
|
+
def click_button_with_popup(browser_handle, property, property_value)
|
15
|
+
browser_handle.button(property.intern, /#{property_value}/).click_no_wait
|
15
16
|
end
|
16
17
|
|
17
18
|
#Double Click a button.
|
18
|
-
def double_click_button(property,
|
19
|
-
|
20
|
-
$ie.button(property.intern,propertyvalue).fire_event("ondblclick")
|
19
|
+
def double_click_button(browser_handle, property, property_value)
|
20
|
+
browser_handle.button(property.intern, /#{property_value}/).fire_event("ondblclick")
|
21
21
|
end
|
22
22
|
|
23
|
-
#Double Click a button
|
24
|
-
def double_click_button_with_popup(property,
|
25
|
-
|
26
|
-
$ie.button(property.intern,propertyvalue).fire_event_no_wait("ondblclick")
|
23
|
+
#Double Click a button, after clicking it a pop-up will come.
|
24
|
+
def double_click_button_with_popup(browser_handle, property, property_value)
|
25
|
+
browser_handle.button(property.intern, /#{property_value}/).fire_event_no_wait("ondblclick")
|
27
26
|
end
|
28
27
|
|
29
28
|
#Highlight or Flash a button.
|
30
|
-
def flash_button(property,
|
31
|
-
|
32
|
-
$ie.button(property.intern,propertyvalue).flash
|
29
|
+
def flash_button(browser_handle, property, property_value)
|
30
|
+
browser_handle.button(property.intern, /#{property_value}/).flash
|
33
31
|
end
|
34
32
|
|
35
33
|
#Check whether a button exists or not.
|
36
|
-
def exists_button(property,
|
37
|
-
|
38
|
-
$ie.button(property.intern,propertyvalue).exists?
|
34
|
+
def exists_button?(browser_handle, property, property_value)
|
35
|
+
browser_handle.button(property.intern, /#{property_value}/).exists?
|
39
36
|
end
|
40
37
|
|
41
38
|
end
|
@@ -1,35 +1,33 @@
|
|
1
|
-
|
1
|
+
#******************************************************
|
2
|
+
#CheckBox methods
|
3
|
+
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
2
5
|
|
3
6
|
module CheckBoxHelper
|
4
7
|
|
5
8
|
#Click a checkbox.
|
6
|
-
def click_checkbox(property,
|
7
|
-
|
8
|
-
$ie.checkbox(property.intern,propertyvalue).set
|
9
|
+
def click_checkbox(browser_handle, property, property_value)
|
10
|
+
browser_handle.checkbox(property.intern, /#{property_value}/).set
|
9
11
|
end
|
10
12
|
|
11
13
|
#Clear a checkbox.
|
12
|
-
def clear_checkbox(property,
|
13
|
-
|
14
|
-
$ie.checkbox(property.intern,propertyvalue).clear
|
14
|
+
def clear_checkbox(browser_handle, property, property_value)
|
15
|
+
browser_handle.checkbox(property.intern, /#{property_value}/).clear
|
15
16
|
end
|
16
17
|
|
17
18
|
#Highlight or Flash a checkbox.
|
18
|
-
def flash_checkbox(property,
|
19
|
-
|
20
|
-
$ie.checkbox(property.intern,propertyvalue).flash
|
19
|
+
def flash_checkbox(browser_handle, property, property_value)
|
20
|
+
browser_handle.checkbox(property.intern, /#{property_value}/).flash
|
21
21
|
end
|
22
22
|
|
23
23
|
#Check whether a checkbox exists or not.
|
24
|
-
def exists_checkbox(property,
|
25
|
-
|
26
|
-
$ie.checkbox(property.intern,propertyvalue).exists?
|
24
|
+
def exists_checkbox?(browser_handle, property, property_value)
|
25
|
+
browser_handle.checkbox(property.intern, /#{property_value}/).exists?
|
27
26
|
end
|
28
27
|
|
29
28
|
#Check whether a checkbox is checked/set or not.
|
30
|
-
def
|
31
|
-
|
32
|
-
$ie.checkbox(property.intern,propertyvalue).checked?
|
29
|
+
def is_checkbox_checked?(browser_handle, property, property_value)
|
30
|
+
browser_handle.checkbox(property.intern, /#{property_value}/).checked?
|
33
31
|
end
|
34
32
|
|
35
33
|
end
|