watir_helper 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +170 -0
- data/lib/watir_helper/browser_helper.rb +62 -0
- data/lib/watir_helper/button_helper.rb +42 -0
- data/lib/watir_helper/checkbox_helper.rb +35 -0
- data/lib/watir_helper/common_helpers.rb +9 -0
- data/lib/watir_helper/div_helper.rb +41 -0
- data/lib/watir_helper/frame_helper.rb +92 -0
- data/lib/watir_helper/image_helper.rb +41 -0
- data/lib/watir_helper/include_all_helpers.rb +51 -0
- data/lib/watir_helper/link_helper.rb +29 -0
- data/lib/watir_helper/login_helper.rb +32 -0
- data/lib/watir_helper/popup_handling_helper.rb +102 -0
- data/lib/watir_helper/radio_button_helper.rb +35 -0
- data/lib/watir_helper/select_list_helper.rb +41 -0
- data/lib/watir_helper/span_helper.rb +17 -0
- data/lib/watir_helper/table_helper.rb +24 -0
- data/lib/watir_helper/textfield_helper.rb +51 -0
- data/lib/watir_helper/validations_helper.rb +144 -0
- data/lib/watir_helper.rb +9 -0
- data/test/testing_watir_helper.rb +37 -0
- data/test/testing_watir_helper_spec.rb +25 -0
- metadata +70 -0
data/README
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
About this Utility:
|
2
|
+
|
3
|
+
This is a utility(watir_helper) developed for making Automation Testing faster, simpler and easier through WATIR.
|
4
|
+
|
5
|
+
Features:-
|
6
|
+
|
7
|
+
1. No need to create an IE Instance.
|
8
|
+
|
9
|
+
2. Just include this gem and use it's parameterized functions some of which are given as follows:-
|
10
|
+
|
11
|
+
# goto_page("http://www.google.com")
|
12
|
+
|
13
|
+
# set_texfield("name","q","Ruby")
|
14
|
+
|
15
|
+
# click_button("name","btnG")
|
16
|
+
|
17
|
+
# verify_text("Ruby")
|
18
|
+
|
19
|
+
# close_browser()
|
20
|
+
|
21
|
+
Due to this feature Automation Testing task will be easier and faster because we have to just use the functions of this gem.
|
22
|
+
|
23
|
+
3. All the functions are available in the lib/watir_helper folder for different type of elements of a website.
|
24
|
+
|
25
|
+
4. Pop-up handling is easy using given parameterized functions in this gem.
|
26
|
+
|
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
|
+
|
35
|
+
Now, You can easily handle pop-up's.
|
36
|
+
|
37
|
+
6. Can add functions into this gem as WATIR is an Open Source tool.
|
38
|
+
|
39
|
+
|
40
|
+
Prerequisites:
|
41
|
+
|
42
|
+
Install Ruby: http://ruby-lang.org
|
43
|
+
|
44
|
+
First you need to install Ruby using the one-click installer for Windows. We
|
45
|
+
recommend Ruby 1.8.6. (Even if you are using modal dialogs.)
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
Install Watir:
|
50
|
+
|
51
|
+
Watir is packaged as a gem, a Ruby library that can be installed over the
|
52
|
+
internet.
|
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.
|
59
|
+
|
60
|
+
To install it, type this at command prompt:
|
61
|
+
|
62
|
+
gem install watir (for latest version)
|
63
|
+
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
|
+
|
71
|
+
gem install rspec -v 1.1.3 (This version is also needed because of some compatibility issue)
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
Install rake:
|
76
|
+
|
77
|
+
gem install rake
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
Install IE Devleoper Toolbar from the site
|
82
|
+
|
83
|
+
http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en
|
84
|
+
|
85
|
+
How
|
86
|
+
To Use:
|
87
|
+
This only works on Windows.Requires Internet Explorer 5.5 or newer.
|
88
|
+
Typical Usage
|
89
|
+
|
90
|
+
# include my utility(watir_helper)
|
91
|
+
|
92
|
+
require 'watir_helper'
|
93
|
+
|
94
|
+
# include the module inside it
|
95
|
+
|
96
|
+
include WatirHelper
|
97
|
+
|
98
|
+
# Go to the Google home page
|
99
|
+
|
100
|
+
goto_page("http://www.google.com/")
|
101
|
+
|
102
|
+
# print Title
|
103
|
+
|
104
|
+
puts get_title
|
105
|
+
|
106
|
+
# print Url
|
107
|
+
|
108
|
+
puts get_url
|
109
|
+
|
110
|
+
# Flash the Google logo on the home page
|
111
|
+
|
112
|
+
flash_image("id","logo")
|
113
|
+
|
114
|
+
# Check whether Google logo image exists or not
|
115
|
+
|
116
|
+
puts exists_image("id","logo")
|
117
|
+
|
118
|
+
# Set the search field to Ruby
|
119
|
+
|
120
|
+
set_textfield("name","q","Ruby")
|
121
|
+
|
122
|
+
# Highlight the Google Search button
|
123
|
+
|
124
|
+
flash_button("value","Google Search")
|
125
|
+
|
126
|
+
# Click the Google Search button
|
127
|
+
|
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
|
+
|
154
|
+
|
155
|
+
Contacts:
|
156
|
+
|
157
|
+
The mailing list: http://groups.google.com/group/watir-general
|
158
|
+
|
159
|
+
E-mail :- ankurgera@gmail.com
|
160
|
+
|
161
|
+
|
162
|
+
yashasree.barve@gmail.com
|
163
|
+
|
164
|
+
Contributors:
|
165
|
+
Ankur Gera
|
166
|
+
|
167
|
+
Yashasree Barve
|
168
|
+
|
169
|
+
Thanks for your ideas and support
|
170
|
+
.
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module BrowserHelper
|
4
|
+
|
5
|
+
#Go to a page.
|
6
|
+
def goto_page(url)
|
7
|
+
$ie.goto(url)
|
8
|
+
end
|
9
|
+
|
10
|
+
#Go to the next page.
|
11
|
+
def goto_next_page()
|
12
|
+
$ie.forward
|
13
|
+
end
|
14
|
+
|
15
|
+
#Go to the previous page.
|
16
|
+
def goto_previous_page()
|
17
|
+
$ie.back
|
18
|
+
end
|
19
|
+
|
20
|
+
#Refresh the page.
|
21
|
+
def refresh_the_page()
|
22
|
+
$ie.refresh
|
23
|
+
end
|
24
|
+
|
25
|
+
#Close the browser.
|
26
|
+
def close_browser()
|
27
|
+
title=get_title()
|
28
|
+
$ai.WinKill(title)
|
29
|
+
end
|
30
|
+
|
31
|
+
#Get the title of the browser.
|
32
|
+
def get_title()
|
33
|
+
$ie.title
|
34
|
+
end
|
35
|
+
|
36
|
+
#Get the url of the browser.
|
37
|
+
def get_url()
|
38
|
+
$ie.url
|
39
|
+
end
|
40
|
+
|
41
|
+
#Attach an IE instance.
|
42
|
+
def attach_an_IE_window(property,propertyvalue)
|
43
|
+
propertyvalue=/#{propertyvalue}/
|
44
|
+
$ie=Watir::IE.attach(property.intern,propertyvalue)
|
45
|
+
end
|
46
|
+
|
47
|
+
#Minimize the browser.
|
48
|
+
def minimize_browser()
|
49
|
+
$ie.minimize
|
50
|
+
end
|
51
|
+
|
52
|
+
#Maximize the browser.
|
53
|
+
def maximize_browser()
|
54
|
+
$ie.maximize
|
55
|
+
end
|
56
|
+
|
57
|
+
#Verify whether text is present or not.
|
58
|
+
def verify_text(text)
|
59
|
+
$ie.text.include?(text)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module ButtonHelper
|
4
|
+
|
5
|
+
#Click a button.
|
6
|
+
def click_button(property,propertyvalue)
|
7
|
+
propertyvalue=/#{propertyvalue}/
|
8
|
+
$ie.button(property.intern,propertyvalue).click
|
9
|
+
end
|
10
|
+
|
11
|
+
#Click a button ,after clicking which a pop-up will come.
|
12
|
+
def click_button_with_popup(property,propertyvalue)
|
13
|
+
propertyvalue=/#{propertyvalue}/
|
14
|
+
$ie.button(property.intern,propertyvalue).click_no_wait
|
15
|
+
end
|
16
|
+
|
17
|
+
#Double Click a button.
|
18
|
+
def double_click_button(property,propertyvalue)
|
19
|
+
propertyvalue=/#{propertyvalue}/
|
20
|
+
$ie.button(property.intern,propertyvalue).fire_event("ondblclick")
|
21
|
+
end
|
22
|
+
|
23
|
+
#Double Click a button ,after clicking which a pop-up will come.
|
24
|
+
def double_click_button_with_popup(property,propertyvalue)
|
25
|
+
propertyvalue=/#{propertyvalue}/
|
26
|
+
$ie.button(property.intern,propertyvalue).fire_event_no_wait("ondblclick")
|
27
|
+
end
|
28
|
+
|
29
|
+
#Highlight or Flash a button.
|
30
|
+
def flash_button(property,propertyvalue)
|
31
|
+
propertyvalue=/#{propertyvalue}/
|
32
|
+
$ie.button(property.intern,propertyvalue).flash
|
33
|
+
end
|
34
|
+
|
35
|
+
#Check whether a button exists or not.
|
36
|
+
def exists_button(property,propertyvalue)
|
37
|
+
propertyvalue=/#{propertyvalue}/
|
38
|
+
$ie.button(property.intern,propertyvalue).exists?
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module CheckBoxHelper
|
4
|
+
|
5
|
+
#Click a checkbox.
|
6
|
+
def click_checkbox(property,propertyvalue)
|
7
|
+
propertyvalue=/#{propertyvalue}/
|
8
|
+
$ie.checkbox(property.intern,propertyvalue).set
|
9
|
+
end
|
10
|
+
|
11
|
+
#Clear a checkbox.
|
12
|
+
def clear_checkbox(property,propertyvalue)
|
13
|
+
propertyvalue=/#{propertyvalue}/
|
14
|
+
$ie.checkbox(property.intern,propertyvalue).clear
|
15
|
+
end
|
16
|
+
|
17
|
+
#Highlight or Flash a checkbox.
|
18
|
+
def flash_checkbox(property,propertyvalue)
|
19
|
+
propertyvalue=/#{propertyvalue}/
|
20
|
+
$ie.checkbox(property.intern,propertyvalue).flash
|
21
|
+
end
|
22
|
+
|
23
|
+
#Check whether a checkbox exists or not.
|
24
|
+
def exists_checkbox(property,propertyvalue)
|
25
|
+
propertyvalue=/#{propertyvalue}/
|
26
|
+
$ie.checkbox(property.intern,propertyvalue).exists?
|
27
|
+
end
|
28
|
+
|
29
|
+
#Check whether a checkbox is checked/set or not.
|
30
|
+
def is_checked_checkbox(property,propertyvalue)
|
31
|
+
propertyvalue=/#{propertyvalue}/
|
32
|
+
$ie.checkbox(property.intern,propertyvalue).checked?
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module DivHelper
|
4
|
+
|
5
|
+
#Click a div.
|
6
|
+
def click_div(property,propertyvalue)
|
7
|
+
propertyvalue=/#{propertyvalue}/
|
8
|
+
$ie.div(property.intern,propertyvalue).click
|
9
|
+
end
|
10
|
+
|
11
|
+
#Click a div, after clicking which a pop-up will come.
|
12
|
+
def click_div_with_popup(property,propertyvalue)
|
13
|
+
propertyvalue=/#{propertyvalue}/
|
14
|
+
$ie.div(property.intern,propertyvalue).click_no_wait
|
15
|
+
end
|
16
|
+
|
17
|
+
#Double Click a div.
|
18
|
+
def double_click_div(property,propertyvalue)
|
19
|
+
propertyvalue=/#{propertyvalue}/
|
20
|
+
$ie.div(property.intern,propertyvalue).fire_event("ondblclick")
|
21
|
+
end
|
22
|
+
|
23
|
+
#Double Click a div, after clicking which a pop-up will come.
|
24
|
+
def double_click_div_with_popup(property,propertyvalue)
|
25
|
+
propertyvalue=/#{propertyvalue}/
|
26
|
+
$ie.div(property.intern,propertyvalue).fire_event_no_wait("ondblclick")
|
27
|
+
end
|
28
|
+
|
29
|
+
#Highlight or Flash a div.
|
30
|
+
def flash_div(property,propertyvalue)
|
31
|
+
propertyvalue=/#{propertyvalue}/
|
32
|
+
$ie.div(property.intern,propertyvalue).flash
|
33
|
+
end
|
34
|
+
|
35
|
+
#Check whether a div exists or not.
|
36
|
+
def exists_div(property,propertyvalue)
|
37
|
+
propertyvalue=/#{propertyvalue}/
|
38
|
+
$ie.div(property.intern,propertyvalue).exists?
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module FrameHelper
|
4
|
+
|
5
|
+
#Click a link inside a frame.
|
6
|
+
def click_link_inside_frame(frame_prop,frame_prop_val,link_prop,link_prop_val)
|
7
|
+
frame_prop_val=/#{frame_prop_val}/
|
8
|
+
link_prop_val=/#{link_prop_val}/
|
9
|
+
$ie.frame(frame_prop.intern,frame_prop_val).link(link_prop.intern,link_prop_val).click
|
10
|
+
end
|
11
|
+
|
12
|
+
#Click a button inside a frame.
|
13
|
+
def click_button_inside_frame(frame_prop,frame_prop_val,button_prop,button_prop_val)
|
14
|
+
frame_prop_val=/#{frame_prop_val}/
|
15
|
+
button_prop_val=/#{button_prop_val}/
|
16
|
+
$ie.frame(frame_prop.intern,frame_prop_val).button(button_prop.intern,button_prop_val).click
|
17
|
+
end
|
18
|
+
|
19
|
+
#Click an image inside a frame.
|
20
|
+
def click_image_inside_frame(frame_prop,frame_prop_val,image_prop,image_prop_val)
|
21
|
+
frame_prop_val=/#{frame_prop_val}/
|
22
|
+
image_prop_val=/#{image_prop_val}/
|
23
|
+
$ie.frame(frame_prop.intern,frame_prop_val).image(image_prop.intern,image_prop_val).click
|
24
|
+
end
|
25
|
+
|
26
|
+
#Click a checkbox inside a frame.
|
27
|
+
def click_checkbox_inside_frame(frame_prop,frame_prop_val,checkbox_prop,checkbox_prop_val)
|
28
|
+
frame_prop_val=/#{frame_prop_val}/
|
29
|
+
checkbox_prop_val=/#{checkbox_prop_val}/
|
30
|
+
$ie.frame(frame_prop.intern,frame_prop_val).checkbox(checkbox_prop.intern,checkbox_prop_val).click
|
31
|
+
end
|
32
|
+
|
33
|
+
#Click a radio button inside a frame.
|
34
|
+
def click_radio_button_inside_frame(frame_prop,frame_prop_val,radio_prop,radio_prop_val)
|
35
|
+
frame_prop_val=/#{frame_prop_val}/
|
36
|
+
radio_prop_val=/#{radio_prop_val}/
|
37
|
+
$ie.frame(frame_prop.intern,frame_prop_val).radio(radio_prop.intern,radio_prop_val).click
|
38
|
+
end
|
39
|
+
|
40
|
+
#Select from a select list inside a frame.
|
41
|
+
def select_from_select_list_inside_frame(frame_prop,frame_prop_val,select_list_prop,select_list_prop_val,select_value)
|
42
|
+
frame_prop_val=/#{frame_prop_val}/
|
43
|
+
select_list_prop_val=/#{select_list_prop_val}/
|
44
|
+
$ie.frame(frame_prop.intern,frame_prop_val).select_list(select_list_prop.intern,select_list_prop_val).select(select_value)
|
45
|
+
end
|
46
|
+
|
47
|
+
#Highlight or Flash a link inside a frame.
|
48
|
+
def flash_link_inside_frame(frame_prop,frame_prop_val,link_prop,link_prop_val)
|
49
|
+
frame_prop_val=/#{frame_prop_val}/
|
50
|
+
link_prop_val=/#{link_prop_val}/
|
51
|
+
$ie.frame(frame_prop.intern,frame_prop_val).link(link_prop.intern,link_prop_val).flash
|
52
|
+
end
|
53
|
+
|
54
|
+
#Highlight or Flash a button inside a frame.
|
55
|
+
def flash_button_inside_frame(frame_prop,frame_prop_val,button_prop,button_prop_val)
|
56
|
+
frame_prop_val=/#{frame_prop_val}/
|
57
|
+
button_prop_val=/#{button_prop_val}/
|
58
|
+
$ie.frame(frame_prop.intern,frame_prop_val).button(button_prop.intern,button_prop_val).flash
|
59
|
+
end
|
60
|
+
|
61
|
+
#Highlight or Flash an image inside a frame.
|
62
|
+
def flash_image_inside_frame(frame_prop,frame_prop_val,image_prop,image_prop_val)
|
63
|
+
frame_prop_val=/#{frame_prop_val}/
|
64
|
+
image_prop_val=/#{image_prop_val}/
|
65
|
+
$ie.frame(frame_prop.intern,frame_prop_val).image(image_prop.intern,image_prop_val).flash
|
66
|
+
end
|
67
|
+
|
68
|
+
#Highlight or Flash a checkbox inside a frame.
|
69
|
+
def flash_checkbox_inside_frame(frame_prop,frame_prop_val,checkbox_prop,checkbox_prop_val)
|
70
|
+
frame_prop_val=/#{frame_prop_val}/
|
71
|
+
checkbox_prop_val=/#{checkbox_prop_val}/
|
72
|
+
$ie.frame(frame_prop.intern,frame_prop_val).checkbox(checkbox_prop.intern,checkbox_prop_val).flash
|
73
|
+
end
|
74
|
+
|
75
|
+
#Highlight or Flash a radio button inside a frame.
|
76
|
+
def flash_radio_button_inside_frame(frame_prop,frame_prop_val,radio_prop,radio_prop_val)
|
77
|
+
frame_prop_val=/#{frame_prop_val}/
|
78
|
+
radio_prop_val=/#{radio_prop_val}/
|
79
|
+
$ie.frame(frame_prop.intern,frame_prop_val).radio(radio_prop.intern,radio_prop_val).flash
|
80
|
+
end
|
81
|
+
|
82
|
+
#Highlight or Flash a select list inside a frame.
|
83
|
+
def flash_select_list_inside_frame(frame_prop,frame_prop_val,select_list_prop,select_list_prop_val)
|
84
|
+
frame_prop_val=/#{frame_prop_val}/
|
85
|
+
select_list_prop_val=/#{select_list_prop_val}/
|
86
|
+
$ie.frame(frame_prop.intern,frame_prop_val).select_list(select_list_prop.intern,select_list_prop_val).flash
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module ImageHelper
|
4
|
+
|
5
|
+
#Click an image.
|
6
|
+
def click_image(property,propertyvalue)
|
7
|
+
propertyvalue=/#{propertyvalue}/
|
8
|
+
$ie.image(property.intern,propertyvalue).click
|
9
|
+
end
|
10
|
+
|
11
|
+
#Click an image ,after clicking which a pop-up will come.
|
12
|
+
def click_image_with_popup(property,propertyvalue)
|
13
|
+
propertyvalue=/#{propertyvalue}/
|
14
|
+
$ie.image(property.intern,propertyvalue).click_no_wait
|
15
|
+
end
|
16
|
+
|
17
|
+
#Double Click an image.
|
18
|
+
def double_click_image(property,propertyvalue)
|
19
|
+
propertyvalue=/#{propertyvalue}/
|
20
|
+
$ie.image(property.intern,propertyvalue).fire_event("ondblclick")
|
21
|
+
end
|
22
|
+
|
23
|
+
#Double Click an image ,after clicking which a pop-up will come.
|
24
|
+
def double_click_image_with_popup(property,propertyvalue)
|
25
|
+
propertyvalue=/#{propertyvalue}/
|
26
|
+
$ie.image(property.intern,propertyvalue).fire_event_no_wait("ondblclick")
|
27
|
+
end
|
28
|
+
|
29
|
+
#Highlight or Flash an image.
|
30
|
+
def flash_image(property,propertyvalue)
|
31
|
+
propertyvalue=/#{propertyvalue}/
|
32
|
+
$ie.image(property.intern,propertyvalue).flash
|
33
|
+
end
|
34
|
+
|
35
|
+
#Check whether an image exists or not.
|
36
|
+
def exists_image(property,propertyvalue)
|
37
|
+
propertyvalue=/#{propertyvalue}/
|
38
|
+
$ie.image(property.intern,propertyvalue).exists?
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'watir_helper/button_helper'
|
2
|
+
include ButtonHelper
|
3
|
+
require 'watir_helper/checkbox_helper'
|
4
|
+
include CheckBoxHelper
|
5
|
+
require 'watir_helper/frame_helper'
|
6
|
+
include FrameHelper
|
7
|
+
require 'watir_helper/image_helper'
|
8
|
+
include ImageHelper
|
9
|
+
require 'watir_helper/link_helper'
|
10
|
+
include LinkHelper
|
11
|
+
|
12
|
+
#Pop Up's Support
|
13
|
+
# Watir now optionally installs AutoIt - http://www.autoitscript.com/
|
14
|
+
# This is the prefered method for dealing wth pop ups, file requesters etc.
|
15
|
+
# To enable the same, execute the following steps on your command prompt
|
16
|
+
# - cd C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.2\lib\watir
|
17
|
+
# - regsvr32 AutoItX3.dll
|
18
|
+
# - You will get a pop-up of successful registration , press "OK" button on it.
|
19
|
+
# Now,You can easily handle pop-up's.
|
20
|
+
require 'watir_helper/popup_handling_helper'
|
21
|
+
include PopupHelper
|
22
|
+
|
23
|
+
require 'watir_helper/radio_button_helper'
|
24
|
+
include RadioButtonHelper
|
25
|
+
require 'watir_helper/select_list_helper'
|
26
|
+
include SelectListHelper
|
27
|
+
require 'watir_helper/textfield_helper'
|
28
|
+
include TextFieldHelper
|
29
|
+
require 'watir_helper/validations_helper'
|
30
|
+
include ValidationsHelper
|
31
|
+
require 'watir_helper/browser_helper'
|
32
|
+
include BrowserHelper
|
33
|
+
require 'watir_helper/login_helper'
|
34
|
+
include LoginHelper
|
35
|
+
require 'watir_helper/span_helper'
|
36
|
+
include SpanHelper
|
37
|
+
require 'watir_helper/table_helper'
|
38
|
+
include TableHelper
|
39
|
+
require 'watir_helper/div_helper'
|
40
|
+
include DivHelper
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module LinkHelper
|
4
|
+
|
5
|
+
#Click a link.
|
6
|
+
def click_link(property,propertyvalue)
|
7
|
+
propertyvalue=/#{propertyvalue}/
|
8
|
+
$ie.link(property.intern,propertyvalue).click
|
9
|
+
end
|
10
|
+
|
11
|
+
#Click a link ,after clicking which a pop-up will come.
|
12
|
+
def click_link_with_popup(property,propertyvalue)
|
13
|
+
propertyvalue=/#{propertyvalue}/
|
14
|
+
$ie.link(property.intern,propertyvalue).click_no_wait
|
15
|
+
end
|
16
|
+
|
17
|
+
#Highlight or Flash a link.
|
18
|
+
def flash_link(property,propertyvalue)
|
19
|
+
propertyvalue=/#{propertyvalue}/
|
20
|
+
$ie.link(property.intern,propertyvalue).flash
|
21
|
+
end
|
22
|
+
|
23
|
+
#Check whether a link exists or not.
|
24
|
+
def exists_link(property,propertyvalue)
|
25
|
+
propertyvalue=/#{propertyvalue}/
|
26
|
+
$ie.link(property.intern,propertyvalue).exists?
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module LoginHelper
|
4
|
+
|
5
|
+
#Login using button into an application.
|
6
|
+
def login_using_button(user_prop,user_prop_value,username,pass_prop,pass_prop_value,password,btn_prop,btn_prop_value)
|
7
|
+
btn_prop=/#{btn_prop}/
|
8
|
+
btn_prop_value=/#{btn_prop_value}/
|
9
|
+
$ie.text_field(user_prop.intern,user_prop_value).set(username)
|
10
|
+
$ie.text_field(pass_prop.intern,pass_prop_value).set(password)
|
11
|
+
$ie.button(btn_prop.intern,btn_prop_value).click
|
12
|
+
end
|
13
|
+
|
14
|
+
#Login using link into an application.
|
15
|
+
def login_using_link(user_prop,user_prop_value,username,pass_prop,pass_prop_value,password,link_prop,link_prop_value)
|
16
|
+
link_prop=/#{link_prop}/
|
17
|
+
link_prop_value=/#{link_prop_value}/
|
18
|
+
$ie.text_field(user_prop.intern,user_prop_value).set(username)
|
19
|
+
$ie.text_field(pass_prop.intern,pass_prop_value).set(password)
|
20
|
+
$ie.link(link_prop.intern,link_prop_value).click
|
21
|
+
end
|
22
|
+
|
23
|
+
#Login using image into an application.
|
24
|
+
def login_using_image(user_prop,user_prop_value,username,pass_prop,pass_prop_value,password,img_prop,img_prop_value)
|
25
|
+
img_prop=/#{img_prop}/
|
26
|
+
img_prop_value=/#{img_prop_value}/
|
27
|
+
$ie.text_field(user_prop.intern,user_prop_value).set(username)
|
28
|
+
$ie.text_field(pass_prop.intern,pass_prop_value).set(password)
|
29
|
+
$ie.image(img_prop.intern,img_prop_value).click
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'win32ole'
|
2
|
+
|
3
|
+
#Pop Up's Support
|
4
|
+
# Watir now optionally installs AutoIt - http://www.autoitscript.com/
|
5
|
+
# This is the prefered method for dealing wth pop ups, file requesters etc.
|
6
|
+
# To enable the same, execute the following steps on your command prompt
|
7
|
+
# - cd C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.2\lib\watir
|
8
|
+
# - regsvr32 AutoItX3.dll
|
9
|
+
# - You will get a pop-up of successful registration , press "OK" button on it.
|
10
|
+
# Now,You can easily handle pop-up's.
|
11
|
+
|
12
|
+
# Note:
|
13
|
+
# The latest version of Watir is 1.6.5 whose close function doesn't work fine if we
|
14
|
+
# handle pop-up's in our scripts.But close function of Watir 1.6.2 works fine with
|
15
|
+
# pop-up handling.
|
16
|
+
|
17
|
+
#Create an OLE connection for handling pop-up's.
|
18
|
+
$ai=WIN32OLE.new("AutoItX3.Control")
|
19
|
+
|
20
|
+
#******************************************************
|
21
|
+
#Pop-up handling methods
|
22
|
+
#******************************************************
|
23
|
+
|
24
|
+
module PopupHelper
|
25
|
+
|
26
|
+
#Javascript pop-up's.
|
27
|
+
|
28
|
+
#Click on a button on a pop-up.
|
29
|
+
def click_a_button_on_a_popup(title,click_element_id)
|
30
|
+
$ai.WinWait(title,"",30)
|
31
|
+
$ai.WinActivate(title)
|
32
|
+
$ai.ControlClick(title,"",click_element_id)
|
33
|
+
end
|
34
|
+
|
35
|
+
#Click on "OK" button on a javascript pop-up.
|
36
|
+
def click_ok_on_javascript_popup(title)
|
37
|
+
click_a_button_on_a_popup(title,"","OK")
|
38
|
+
end
|
39
|
+
|
40
|
+
#Click on "Cancel" button on a javascript pop-up.
|
41
|
+
def click_cancel_on_javascript_popup(title)
|
42
|
+
click_a_button_on_a_popup(title,"","Cancel")
|
43
|
+
end
|
44
|
+
|
45
|
+
#Click on "Yes" button on a javascript pop-up.
|
46
|
+
def click_yes_on_javascript_popup(title)
|
47
|
+
click_a_button_on_a_popup(title,"","&Yes")
|
48
|
+
end
|
49
|
+
|
50
|
+
#Click on "No" button on a javascript pop-up.
|
51
|
+
def click_no_on_javascript_popup(title)
|
52
|
+
click_a_button_on_a_popup(title,"","&No")
|
53
|
+
end
|
54
|
+
|
55
|
+
#File Dialogs
|
56
|
+
#Click on "Open" button on a file dialog pop-up.
|
57
|
+
def click_open_on_file_dialog_popup(title)
|
58
|
+
click_a_button_on_a_popup(title,"&Open")
|
59
|
+
end
|
60
|
+
|
61
|
+
#Click on "Save" button on a file dialog pop-up.
|
62
|
+
def click_save_on_file_dialog_popup(title)
|
63
|
+
click_a_button_on_a_popup(title,"&Save")
|
64
|
+
end
|
65
|
+
|
66
|
+
#Click on "Cancel" button on a file dialog pop-up.
|
67
|
+
def click_cancel_on_file_dialog_popup(title)
|
68
|
+
click_a_button_on_a_popup(title,"Cancel")
|
69
|
+
end
|
70
|
+
|
71
|
+
#Save As
|
72
|
+
#Click on a button on a Save As or Open pop-up.
|
73
|
+
def click_a_button_on_save_or_open_popup(title,file_path,click_element_id)
|
74
|
+
$ai.WinWait(title,"",30)
|
75
|
+
$ai.WinActivate(title)
|
76
|
+
$ai.ControlSend(title,"","Edit1",file_path)
|
77
|
+
$ai.ControlClick(title,"",click_element_id)
|
78
|
+
end
|
79
|
+
|
80
|
+
#Click on "Save" button on a Save As pop-up.
|
81
|
+
def click_save_on_save_as_popup(title,save_file_path)
|
82
|
+
click_a_button_on_save_or_open_popup(title,save_file_path,"&Save")
|
83
|
+
end
|
84
|
+
|
85
|
+
#Click on "Cancel" button on a Save As pop-up.
|
86
|
+
def click_cancel_on_save_as_popup(title,save_file_path)
|
87
|
+
click_a_button_on_save_or_open_popup(title,save_file_path,"Cancel")
|
88
|
+
end
|
89
|
+
|
90
|
+
#Open
|
91
|
+
#Click on "Open" button on an Open pop-up.
|
92
|
+
def click_open_on_open_as_popup(title,open_file_path)
|
93
|
+
click_a_button_on_save_or_open_popup(title,open_file_path,"&Open")
|
94
|
+
end
|
95
|
+
|
96
|
+
#Click on "Cancel" button on an Open pop-up.
|
97
|
+
def click_cancel_on_open_as_popup(title,open_file_path)
|
98
|
+
click_a_button_on_save_or_open_popup(title,open_file_path,"Cancel")
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module RadioButtonHelper
|
4
|
+
|
5
|
+
#Click a radio button.
|
6
|
+
def click_radio_button(property,propertyvalue)
|
7
|
+
propertyvalue=/#{propertyvalue}/
|
8
|
+
$ie.radio(property.intern,propertyvalue).set
|
9
|
+
end
|
10
|
+
|
11
|
+
#Clear a radio button.
|
12
|
+
def clear_radio_button(property,propertyvalue)
|
13
|
+
propertyvalue=/#{propertyvalue}/
|
14
|
+
$ie.radio(property.intern,propertyvalue).clear
|
15
|
+
end
|
16
|
+
|
17
|
+
#Highlight or Flash a radio button.
|
18
|
+
def flash_radio_button(property,propertyvalue)
|
19
|
+
propertyvalue=/#{propertyvalue}/
|
20
|
+
$ie.radio(property.intern,propertyvalue).flash
|
21
|
+
end
|
22
|
+
|
23
|
+
#Check whether a radio button exists or not.
|
24
|
+
def exists_radio_button(property,propertyvalue)
|
25
|
+
propertyvalue=/#{propertyvalue}/
|
26
|
+
$ie.radio(property.intern,propertyvalue).exists?
|
27
|
+
end
|
28
|
+
|
29
|
+
#Check whether a radio button is checked or not.
|
30
|
+
def is_checked_radio_button(property,propertyvalue)
|
31
|
+
propertyvalue=/#{propertyvalue}/
|
32
|
+
$ie.radio(property.intern,propertyvalue).checked?
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module SelectListHelper
|
4
|
+
|
5
|
+
#Select from a Select list.
|
6
|
+
def select_from_select_list(property,propertyvalue,selected_value)
|
7
|
+
propertyvalue=/#{propertyvalue}/
|
8
|
+
$ie.select_list(property.intern,propertyvalue).select(selected_value)
|
9
|
+
end
|
10
|
+
|
11
|
+
#Clear selection from a Select list.
|
12
|
+
def clear_selection_from_select_list(property,propertyvalue)
|
13
|
+
propertyvalue=/#{propertyvalue}/
|
14
|
+
$ie.select_list(property.intern,propertyvalue).clearSelection
|
15
|
+
end
|
16
|
+
|
17
|
+
#Get all contents of a Select list.
|
18
|
+
def get_all_contents_of_select_list(property,propertyvalue)
|
19
|
+
propertyvalue=/#{propertyvalue}/
|
20
|
+
$ie.select_list(property.intern,propertyvalue).getAllContents
|
21
|
+
end
|
22
|
+
|
23
|
+
#Highlight or Flash a Select list.
|
24
|
+
def flash_select_list(property,propertyvalue)
|
25
|
+
propertyvalue=/#{propertyvalue}/
|
26
|
+
$ie.select_list(property.intern,propertyvalue).flash
|
27
|
+
end
|
28
|
+
|
29
|
+
#Check whether a Select list exists or not.
|
30
|
+
def exists_select_list(property,propertyvalue)
|
31
|
+
propertyvalue=/#{propertyvalue}/
|
32
|
+
$ie.select_list(property.intern,propertyvalue).exists?
|
33
|
+
end
|
34
|
+
|
35
|
+
#Check whether a particular value is selected from a Select list or not.
|
36
|
+
def is_value_selected_from_select_list(property,propertyvalue,selected_value)
|
37
|
+
propertyvalue=/#{propertyvalue}/
|
38
|
+
$ie.select_list(property.intern,propertyvalue).selected?(selected_value)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module SpanHelper
|
4
|
+
|
5
|
+
#Highlight or Flash a span.
|
6
|
+
def flash_span(property,propertyvalue)
|
7
|
+
propertyvalue=/#{propertyvalue}/
|
8
|
+
$ie.span(property.intern,propertyvalue).flash
|
9
|
+
end
|
10
|
+
|
11
|
+
#Check whether a span exists or not.
|
12
|
+
def exists_span(property,propertyvalue)
|
13
|
+
propertyvalue=/#{propertyvalue}/
|
14
|
+
$ie.span(property.intern,propertyvalue).exists?
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module TableHelper
|
4
|
+
|
5
|
+
#Highlight or Flash a table.
|
6
|
+
def flash_table(property,propertyvalue)
|
7
|
+
propertyvalue=/#{propertyvalue}/
|
8
|
+
$ie.table(property.intern,propertyvalue).flash
|
9
|
+
end
|
10
|
+
|
11
|
+
#Check whether a table exists or not.
|
12
|
+
def exists_table(property,propertyvalue)
|
13
|
+
propertyvalue=/#{propertyvalue}/
|
14
|
+
$ie.table(property.intern,propertyvalue).exists?
|
15
|
+
end
|
16
|
+
|
17
|
+
#Return the table contents.
|
18
|
+
def return_table_contents(property,propertyvalue)
|
19
|
+
propertyvalue=/#{propertyvalue}/
|
20
|
+
$ie.table(property.intern,propertyvalue).to_a
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module TextFieldHelper
|
4
|
+
|
5
|
+
#Set a texfield with a text.
|
6
|
+
def set_textfield(property,propertyvalue,settextvalue)
|
7
|
+
$settext=settextvalue
|
8
|
+
$ie.text_field(property.intern,propertyvalue).set settextvalue
|
9
|
+
end
|
10
|
+
|
11
|
+
#Get the text from the textfield.
|
12
|
+
def get_textfield()
|
13
|
+
if $settext.nil?
|
14
|
+
return nil
|
15
|
+
else
|
16
|
+
return $settext
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#Clear a texfield.
|
21
|
+
def clear_textfield(property,propertyvalue)
|
22
|
+
propertyvalue=/#{propertyvalue}/
|
23
|
+
$ie.text_field(property.intern,propertyvalue).clear
|
24
|
+
end
|
25
|
+
|
26
|
+
#Highlight or Flash a textfield.
|
27
|
+
def flash_textfield(property,propertyvalue)
|
28
|
+
propertyvalue=/#{propertyvalue}/
|
29
|
+
$ie.text_field(property.intern,propertyvalue).flash
|
30
|
+
end
|
31
|
+
|
32
|
+
#Check whether a textfield exists or not.
|
33
|
+
def exists_textfield(property,propertyvalue)
|
34
|
+
propertyvalue=/#{propertyvalue}/
|
35
|
+
$ie.text_field(property.intern,propertyvalue).exists?
|
36
|
+
end
|
37
|
+
|
38
|
+
#Check whether a textfield is blank or not.
|
39
|
+
def is_blank_textfield()
|
40
|
+
return $settext.nil? ? true : false
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'watir_helper/common_helpers'
|
2
|
+
|
3
|
+
module ValidationsHelper
|
4
|
+
|
5
|
+
#Check whether a character range is present in a textfield or not.
|
6
|
+
def validate_chars_range_contain_textfield(range_start,range_end) #for positive integers and chars range
|
7
|
+
if (range_start <= range_end) and (range_start.length==1) and (range_end.length==1)
|
8
|
+
puts $settext.gsub(/[#{range_start}-#{range_end}]/,'*').index('*')? "Present" : "Not Present"
|
9
|
+
else
|
10
|
+
puts "Error!!! :-Please input a valid range"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
#Check whether a substring is present in a textfield or not.
|
15
|
+
def contains_sub_string(substring)
|
16
|
+
return $settext.sub(substring,'*').index('*') ? true : false
|
17
|
+
end
|
18
|
+
|
19
|
+
#Check whether a date is in mmddyyyy format or not.
|
20
|
+
def validate_date_format_mmddyyyy(date)
|
21
|
+
if(date =~ /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$/).nil?
|
22
|
+
puts "Invalid Date(mmddyyyy) Format"
|
23
|
+
else
|
24
|
+
puts "Valid Date(mmddyyyy) Format"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#Check whether a date is in ddmmyyyy format or not.
|
29
|
+
def validate_date_format_ddmmyyyy(date)
|
30
|
+
if(date=~/^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.](19|20)\d\d$/).nil?
|
31
|
+
puts "Invalid Date(ddmmyyyy) Format"
|
32
|
+
else
|
33
|
+
puts "Valid Date(ddmmyyyy) Format"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#Check whether the age entered is in the given range or not.
|
38
|
+
def is_age_in_the_range(range_start,range_end)
|
39
|
+
if ($settext.to_i>=range_start.to_i and $settext.to_i<=range_end.to_i)
|
40
|
+
return true
|
41
|
+
else
|
42
|
+
return false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
#Check whether e-mail adress supplied is valid or not.
|
47
|
+
def validate_email_address(email_id)
|
48
|
+
if(email_id=~/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/).nil?
|
49
|
+
puts "Invalid E-mail id Format"
|
50
|
+
else
|
51
|
+
puts "Valid E-mail id Format"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#Check whether the indian mobile number entered is valid or not.
|
56
|
+
def validate_indian_mobile_number(mobile_no)
|
57
|
+
if(mobile_no.to_i>0)
|
58
|
+
if(mobile_no.length==10)
|
59
|
+
if(mobile_no=~/^([9]{1})([023456789]{1})([0-9]{8})$/).nil?
|
60
|
+
puts "Wrong Mobile number format"
|
61
|
+
else
|
62
|
+
puts "Correct Mobile number format"
|
63
|
+
end
|
64
|
+
elsif(mobile_no.length<10)
|
65
|
+
puts "Error!!!! :- Mobile number length is less than 10 digit"
|
66
|
+
elsif(mobile_no.length>10)
|
67
|
+
puts "Error!!!! :- Mobile number length is more than 10 digit"
|
68
|
+
end
|
69
|
+
else
|
70
|
+
puts "Error!!!! :- Mobile number can't be negative"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
#Check whether the indian landline number entered is valid or not.
|
75
|
+
def validate_indian_landline_number(landline_no)#like "020-30303030"
|
76
|
+
if(landline_no.length==12) #In India landline number should be of 10 digits including std code
|
77
|
+
#Here we will prefix "0" before std code and "-" between std code and the respective landline number
|
78
|
+
if(landline_no=~/^[0]{1}[1-9]{1}[0-9]{1,3}[\-]{1}[1-9]{1}[0-9]{5,7}$/).nil?
|
79
|
+
puts "Wrong Landline number format"
|
80
|
+
else
|
81
|
+
puts "Correct Landline number format"
|
82
|
+
end
|
83
|
+
else
|
84
|
+
puts "Error!!!! :- Wrong Landline number format"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
#Check whether the value entered is an Integer or not.
|
89
|
+
def is_an_Integer(value)
|
90
|
+
value.is_a?(Integer)
|
91
|
+
end
|
92
|
+
|
93
|
+
#Check whether the value entered is a Float or not.
|
94
|
+
def is_a_Float(value)
|
95
|
+
value.is_a?(Float)
|
96
|
+
end
|
97
|
+
|
98
|
+
#Check whether the value entered is a String or not.
|
99
|
+
def is_a_String(value)
|
100
|
+
value.is_a?(String)
|
101
|
+
end
|
102
|
+
|
103
|
+
#Check whether the value entered is a Regular Expression or not.
|
104
|
+
def is_a_reg_exp(value)
|
105
|
+
value.is_a?(Regexp)
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
#Check whether the value entered is a Character or not.
|
110
|
+
def is_a_char(value) #Like "3",'3',"a",'a'
|
111
|
+
value.length==1
|
112
|
+
end
|
113
|
+
|
114
|
+
#Check whether the value entered contains a string or not.
|
115
|
+
def contain_chars(char_set)
|
116
|
+
is_string_contains_character_set($settext,char_set)
|
117
|
+
end
|
118
|
+
|
119
|
+
#Check whether a string contains a regular expression or not.
|
120
|
+
def is_string_contains_reg_exp_character_set(char_string,char_set)
|
121
|
+
flag=0 #Here char_set is a regular expression of characters
|
122
|
+
#The format for regular expression of character set(or char_set) should be like /[$#!@^*&()~]/
|
123
|
+
if(char_string.sub(char_set,'**').index('**') ? true : false)==true
|
124
|
+
flag=1
|
125
|
+
end
|
126
|
+
flag==1
|
127
|
+
end
|
128
|
+
|
129
|
+
#Check whether a string contains another string or not.
|
130
|
+
def is_string_contains_character_set(char_string,char_set)
|
131
|
+
flag=0 #Here char_set is a string of characters
|
132
|
+
char_set.each_byte do |char|
|
133
|
+
if(char_string.sub(char.chr.to_s,'**').index('**') ? true : false )==true
|
134
|
+
flag=1
|
135
|
+
end
|
136
|
+
end
|
137
|
+
flag==1
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
data/lib/watir_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'watir_helper'
|
2
|
+
include WatirHelper
|
3
|
+
|
4
|
+
goto_page("http://www.google.com/")
|
5
|
+
puts get_title
|
6
|
+
puts get_url
|
7
|
+
flash_div("id","hplogo")
|
8
|
+
puts exists_div("id","hplogo")
|
9
|
+
set_textfield("name","q","Ruby")
|
10
|
+
flash_button("value","Google Search")
|
11
|
+
click_button("value","Google Search")
|
12
|
+
|
13
|
+
|
14
|
+
#Pop Up's Support
|
15
|
+
# Watir now optionally installs AutoIt - http://www.autoitscript.com/
|
16
|
+
# This is the prefered method for dealing wth pop ups, file requesters etc.
|
17
|
+
# To enable the same, execute the following steps on your command prompt
|
18
|
+
# - cd C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.2\lib\watir
|
19
|
+
# - regsvr32 AutoItX3.dll
|
20
|
+
# - You will get a pop-up of successful registration , press "OK" button on it.
|
21
|
+
# Now,You can easily handle pop-up's.
|
22
|
+
|
23
|
+
# Note:
|
24
|
+
# The latest version of Watir is 1.6.5 whose close function doesn't work fine if we
|
25
|
+
# handle pop-up's in our scripts.But close function of Watir 1.6.2 works fine with
|
26
|
+
# pop-up handling.
|
27
|
+
|
28
|
+
#goto_page("http://www.autoitscript.com/autoit3/downloads.shtml")
|
29
|
+
#click_image_with_popup("src","download_autoit")
|
30
|
+
#click_save_on_file_dialog_popup("File Download - Security Warning")
|
31
|
+
#click_save_on_save_as_popup("Save As","C:\AutoItV3.exe")
|
32
|
+
#puts get_title
|
33
|
+
#puts get_url
|
34
|
+
|
35
|
+
close_browser()
|
36
|
+
|
37
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'watir_helper'
|
2
|
+
include WatirHelper
|
3
|
+
|
4
|
+
describe "Scenario :- Google page test" do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
goto_page("http://www.google.com/")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "Should verify whether we are on the Landing Page or not" do
|
11
|
+
puts get_title
|
12
|
+
puts get_url
|
13
|
+
flash_image("id","logo")
|
14
|
+
puts exists_image("id","logo")
|
15
|
+
set_textfield("name","q","Ruby")
|
16
|
+
flash_button("value","Google Search")
|
17
|
+
click_button("value","Google Search")
|
18
|
+
end
|
19
|
+
|
20
|
+
after(:all) do
|
21
|
+
close_browser()
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: watir_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ankur Gera
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-06-16 00:00:00.000000000 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
description:
|
16
|
+
email: ankurgera@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- README
|
21
|
+
files:
|
22
|
+
- lib/watir_helper/browser_helper.rb
|
23
|
+
- lib/watir_helper/button_helper.rb
|
24
|
+
- lib/watir_helper/checkbox_helper.rb
|
25
|
+
- lib/watir_helper/common_helpers.rb
|
26
|
+
- lib/watir_helper/div_helper.rb
|
27
|
+
- lib/watir_helper/frame_helper.rb
|
28
|
+
- lib/watir_helper/image_helper.rb
|
29
|
+
- lib/watir_helper/include_all_helpers.rb
|
30
|
+
- lib/watir_helper/link_helper.rb
|
31
|
+
- lib/watir_helper/login_helper.rb
|
32
|
+
- lib/watir_helper/popup_handling_helper.rb
|
33
|
+
- lib/watir_helper/radio_button_helper.rb
|
34
|
+
- lib/watir_helper/select_list_helper.rb
|
35
|
+
- lib/watir_helper/span_helper.rb
|
36
|
+
- lib/watir_helper/table_helper.rb
|
37
|
+
- lib/watir_helper/textfield_helper.rb
|
38
|
+
- lib/watir_helper/validations_helper.rb
|
39
|
+
- lib/watir_helper.rb
|
40
|
+
- test/testing_watir_helper.rb
|
41
|
+
- test/testing_watir_helper_spec.rb
|
42
|
+
- README
|
43
|
+
has_rdoc: true
|
44
|
+
homepage:
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.5.2
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: A utility for making Automation Testing faster, simpler and easier.
|
68
|
+
test_files:
|
69
|
+
- test/testing_watir_helper.rb
|
70
|
+
- test/testing_watir_helper_spec.rb
|