watir_helper 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,32 +1,29 @@
|
|
1
|
-
|
1
|
+
#******************************************************
|
2
|
+
#Login methods
|
3
|
+
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
2
5
|
|
3
6
|
module LoginHelper
|
4
7
|
|
5
8
|
#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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
$ie.text_field(pass_prop.intern,pass_prop_value).set(password)
|
11
|
-
$ie.button(btn_prop.intern,btn_prop_value).click
|
9
|
+
def login_using_button(browser_handle, user_prop, user_prop_value, username, pass_prop, pass_prop_value, password, btn_prop, btn_prop_value)
|
10
|
+
browser_handle.text_field(user_prop.intern,user_prop_value).set(username)
|
11
|
+
browser_handle.text_field(pass_prop.intern,pass_prop_value).set(password)
|
12
|
+
browser_handle.button(/#{btn_prop}/.intern, /#{btn_prop_value}/).click
|
12
13
|
end
|
13
14
|
|
14
15
|
#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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
$ie.text_field(pass_prop.intern,pass_prop_value).set(password)
|
20
|
-
$ie.link(link_prop.intern,link_prop_value).click
|
16
|
+
def login_using_link(browser_handle, user_prop, user_prop_value, username, pass_prop, pass_prop_value, password, link_prop, link_prop_value)
|
17
|
+
browser_handle.text_field(user_prop.intern,user_prop_value).set(username)
|
18
|
+
browser_handle.text_field(pass_prop.intern,pass_prop_value).set(password)
|
19
|
+
browser_handle.link(/#{link_prop}/.intern, /#{link_prop_value}/).click
|
21
20
|
end
|
22
21
|
|
23
22
|
#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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
$ie.text_field(pass_prop.intern,pass_prop_value).set(password)
|
29
|
-
$ie.image(img_prop.intern,img_prop_value).click
|
23
|
+
def login_using_image(browser_handle, user_prop, user_prop_value, username, pass_prop, pass_prop_value, password, img_prop, img_prop_value)
|
24
|
+
browser_handle.text_field(user_prop.intern,user_prop_value).set(username)
|
25
|
+
browser_handle.text_field(pass_prop.intern,pass_prop_value).set(password)
|
26
|
+
browser_handle.image(/#{img_prop}/.intern, /#{img_prop_value}/).click
|
30
27
|
end
|
31
28
|
|
32
29
|
end
|
@@ -1,102 +1,98 @@
|
|
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
1
|
#******************************************************
|
21
2
|
#Pop-up handling methods
|
22
3
|
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
23
5
|
|
24
6
|
module PopupHelper
|
25
7
|
|
26
|
-
#Javascript pop-up's
|
8
|
+
#Javascript pop-up's
|
27
9
|
|
28
|
-
#Click
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
$ai.ControlClick(title,"",click_element_id)
|
10
|
+
#Click a button on a pop-up.
|
11
|
+
def click_button_popup(title, button_id)
|
12
|
+
window = RAutomation::Window.new(:title => /#{title}/)
|
13
|
+
window.button(:value => /#{button_id}/).click
|
33
14
|
end
|
34
|
-
|
35
|
-
#
|
36
|
-
def
|
37
|
-
|
15
|
+
|
16
|
+
#Pop-up window exists
|
17
|
+
def popup_exists_with_title?(title)
|
18
|
+
window = RAutomation::Window.new(:title => /#{title}/)
|
19
|
+
window.exists?
|
38
20
|
end
|
39
21
|
|
40
|
-
#Click
|
41
|
-
def
|
42
|
-
|
22
|
+
#Click "OK" button on a javascript pop-up.
|
23
|
+
def click_ok_js_popup(title)
|
24
|
+
click_button_popup(title, "OK")
|
43
25
|
end
|
44
26
|
|
45
|
-
#Click
|
46
|
-
def
|
47
|
-
|
27
|
+
#Click "Cancel" button on a javascript pop-up.
|
28
|
+
def click_cancel_js_popup(title)
|
29
|
+
click_button_popup(title, "Cancel")
|
48
30
|
end
|
49
31
|
|
50
|
-
#Click
|
51
|
-
def
|
52
|
-
|
32
|
+
#Click "Yes" button on a javascript pop-up.
|
33
|
+
def click_yes_js_popup(title)
|
34
|
+
click_button_popup(title, "&Yes")
|
35
|
+
end
|
36
|
+
|
37
|
+
#Click "Yes" button on a javascript pop-up.
|
38
|
+
def click_yes_to_all_js_popup(title)
|
39
|
+
click_button_popup(title, "Yes To &All")
|
40
|
+
end
|
41
|
+
|
42
|
+
#Click "No" button on a javascript pop-up.
|
43
|
+
def click_no_js_popup(title)
|
44
|
+
click_button_popup(title, "&No")
|
53
45
|
end
|
54
46
|
|
55
47
|
#File Dialogs
|
56
|
-
|
57
|
-
|
58
|
-
|
48
|
+
|
49
|
+
#Click "Open" button on a file dialog pop-up.
|
50
|
+
def click_open_file_dialog_popup(title)
|
51
|
+
click_button_popup(title, "&Open")
|
59
52
|
end
|
60
53
|
|
61
|
-
#Click
|
62
|
-
def
|
63
|
-
|
54
|
+
#Click "Save" button on a file dialog pop-up.
|
55
|
+
def click_save_file_dialog_popup(title)
|
56
|
+
click_button_popup(title, "&Save")
|
64
57
|
end
|
65
58
|
|
66
|
-
#Click
|
67
|
-
def
|
68
|
-
|
59
|
+
#Click "Cancel" button on a file dialog pop-up.
|
60
|
+
def click_cancel_file_dialog_popup(title)
|
61
|
+
click_button_popup(title, "Cancel")
|
69
62
|
end
|
70
63
|
|
71
|
-
#
|
72
|
-
|
73
|
-
|
74
|
-
$ai.WinWait(title,"",30)
|
75
|
-
$ai.WinActivate(title)
|
76
|
-
$ai.ControlSend(title,"","Edit1",file_path)
|
77
|
-
$ai.ControlClick(title,"",click_element_id)
|
64
|
+
#Click "Run" button on a file dialog pop-up.
|
65
|
+
def click_run_file_dialog_popup(title)
|
66
|
+
click_button_popup(title, "&Run")
|
78
67
|
end
|
79
68
|
|
80
|
-
#
|
81
|
-
|
82
|
-
|
69
|
+
#Save As or Open As pop-up's
|
70
|
+
|
71
|
+
#Click a button on 'Save As' or 'Open As' pop-up's.
|
72
|
+
def click_button_saveas_or_openas_popup(title, file_path, button_id)
|
73
|
+
window = RAutomation::Window.new :title => /#{title}/
|
74
|
+
window.text_field(:class => "Edit").set file_path
|
75
|
+
window.button(:value => /#{button_id}/).click
|
83
76
|
end
|
84
77
|
|
85
|
-
#Click
|
86
|
-
def
|
87
|
-
|
78
|
+
#Click "Save" button on 'Save As' pop-up's.
|
79
|
+
def click_save_saveas_popup(title, save_file_path)
|
80
|
+
click_button_saveas_or_openas_popup(title, save_file_path, "&Save")
|
88
81
|
end
|
89
82
|
|
90
|
-
#
|
91
|
-
|
92
|
-
|
93
|
-
click_a_button_on_save_or_open_popup(title,open_file_path,"&Open")
|
83
|
+
#Click "Cancel" button on 'Save As' pop-up's.
|
84
|
+
def click_cancel_saveas_popup(title, save_file_path)
|
85
|
+
click_button_saveas_or_openas_popup(title, save_file_path, "Cancel")
|
94
86
|
end
|
95
87
|
|
96
|
-
#Click
|
97
|
-
def
|
98
|
-
|
88
|
+
#Click "Open" button on 'Open As' pop-up's.
|
89
|
+
def click_open_openas_popup(title, open_file_path)
|
90
|
+
click_button_saveas_or_openas_popup(title, open_file_path, "&Open")
|
99
91
|
end
|
100
92
|
|
93
|
+
#Click "Cancel" button on 'Open As' pop-up's.
|
94
|
+
def click_cancel_openas_popup(title, open_file_path)
|
95
|
+
click_button_saveas_or_openas_popup(title, open_file_path, "Cancel")
|
101
96
|
end
|
102
97
|
|
98
|
+
end
|
@@ -1,35 +1,33 @@
|
|
1
|
-
|
1
|
+
#******************************************************
|
2
|
+
#Radio Button methods
|
3
|
+
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
2
5
|
|
3
6
|
module RadioButtonHelper
|
4
7
|
|
5
8
|
#Click a radio button.
|
6
|
-
def click_radio_button(property,
|
7
|
-
|
8
|
-
$ie.radio(property.intern,propertyvalue).set
|
9
|
+
def click_radio_button(browser_handle, property, property_value)
|
10
|
+
browser_handle.radio(property.intern, /#{property_value}/).set
|
9
11
|
end
|
10
12
|
|
11
13
|
#Clear a radio button.
|
12
|
-
def clear_radio_button(property,
|
13
|
-
|
14
|
-
$ie.radio(property.intern,propertyvalue).clear
|
14
|
+
def clear_radio_button(browser_handle, property, property_value)
|
15
|
+
browser_handle.radio(property.intern, /#{property_value}/).clear
|
15
16
|
end
|
16
17
|
|
17
18
|
#Highlight or Flash a radio button.
|
18
|
-
def flash_radio_button(property,
|
19
|
-
|
20
|
-
$ie.radio(property.intern,propertyvalue).flash
|
19
|
+
def flash_radio_button(browser_handle, property, property_value)
|
20
|
+
browser_handle.radio(property.intern, /#{property_value}/).flash
|
21
21
|
end
|
22
22
|
|
23
23
|
#Check whether a radio button exists or not.
|
24
|
-
def exists_radio_button(property,
|
25
|
-
|
26
|
-
$ie.radio(property.intern,propertyvalue).exists?
|
24
|
+
def exists_radio_button?(browser_handle, property, property_value)
|
25
|
+
browser_handle.radio(property.intern, /#{property_value}/).exists?
|
27
26
|
end
|
28
27
|
|
29
28
|
#Check whether a radio button is checked or not.
|
30
|
-
def
|
31
|
-
|
32
|
-
$ie.radio(property.intern,propertyvalue).checked?
|
29
|
+
def is_radio_button_checked?(browser_handle, property, property_value)
|
30
|
+
browser_handle.radio(property.intern, /#{property_value}/).checked?
|
33
31
|
end
|
34
32
|
|
35
33
|
end
|
@@ -1,41 +1,38 @@
|
|
1
|
-
|
1
|
+
#******************************************************
|
2
|
+
#Select List methods
|
3
|
+
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
2
5
|
|
3
6
|
module SelectListHelper
|
4
7
|
|
5
8
|
#Select from a Select list.
|
6
|
-
def select_from_select_list(property,
|
7
|
-
|
8
|
-
$ie.select_list(property.intern,propertyvalue).select(selected_value)
|
9
|
+
def select_from_select_list(browser_handle, property, property_value, selected_value)
|
10
|
+
browser_handle.select_list(property.intern, /#{property_value}/).select(selected_value)
|
9
11
|
end
|
10
12
|
|
11
13
|
#Clear selection from a Select list.
|
12
|
-
def clear_selection_from_select_list(property,
|
13
|
-
|
14
|
-
$ie.select_list(property.intern,propertyvalue).clearSelection
|
14
|
+
def clear_selection_from_select_list(browser_handle, property, property_value)
|
15
|
+
browser_handle.select_list(property.intern, /#{property_value}/).clearSelection
|
15
16
|
end
|
16
17
|
|
17
18
|
#Get all contents of a Select list.
|
18
|
-
def get_all_contents_of_select_list(property,
|
19
|
-
|
20
|
-
$ie.select_list(property.intern,propertyvalue).getAllContents
|
19
|
+
def get_all_contents_of_select_list(browser_handle, property, property_value)
|
20
|
+
browser_handle.select_list(property.intern, /#{property_value}/).getAllContents
|
21
21
|
end
|
22
22
|
|
23
23
|
#Highlight or Flash a Select list.
|
24
|
-
def flash_select_list(property,
|
25
|
-
|
26
|
-
$ie.select_list(property.intern,propertyvalue).flash
|
24
|
+
def flash_select_list(browser_handle, property, property_value)
|
25
|
+
browser_handle.select_list(property.intern, /#{property_value}/).flash
|
27
26
|
end
|
28
27
|
|
29
28
|
#Check whether a Select list exists or not.
|
30
|
-
def exists_select_list(property,
|
31
|
-
|
32
|
-
$ie.select_list(property.intern,propertyvalue).exists?
|
29
|
+
def exists_select_list?(browser_handle, property, property_value)
|
30
|
+
browser_handle.select_list(property.intern, /#{property_value}/).exists?
|
33
31
|
end
|
34
32
|
|
35
33
|
#Check whether a particular value is selected from a Select list or not.
|
36
|
-
def is_value_selected_from_select_list(property,
|
37
|
-
|
38
|
-
$ie.select_list(property.intern,propertyvalue).selected?(selected_value)
|
34
|
+
def is_value_selected_from_select_list?(browser_handle, property, property_value, selected_value)
|
35
|
+
browser_handle.select_list(property.intern, /#{property_value}/).selected?(selected_value)
|
39
36
|
end
|
40
37
|
|
41
38
|
end
|
@@ -1,17 +1,18 @@
|
|
1
|
-
|
1
|
+
#******************************************************
|
2
|
+
#Span methods
|
3
|
+
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
2
5
|
|
3
6
|
module SpanHelper
|
4
7
|
|
5
8
|
#Highlight or Flash a span.
|
6
|
-
def flash_span(property,
|
7
|
-
|
8
|
-
$ie.span(property.intern,propertyvalue).flash
|
9
|
+
def flash_span(browser_handle, property, property_value)
|
10
|
+
browser_handle.span(property.intern, /#{property_value}/).flash
|
9
11
|
end
|
10
12
|
|
11
13
|
#Check whether a span exists or not.
|
12
|
-
def exists_span(property,
|
13
|
-
|
14
|
-
$ie.span(property.intern,propertyvalue).exists?
|
14
|
+
def exists_span?(browser_handle, property, property_value)
|
15
|
+
browser_handle.span(property.intern, /#{property_value}/).exists?
|
15
16
|
end
|
16
17
|
|
17
18
|
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
|
1
|
+
#******************************************************
|
2
|
+
#Table methods
|
3
|
+
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
2
5
|
|
3
6
|
module TableHelper
|
4
7
|
|
5
8
|
#Highlight or Flash a table.
|
6
|
-
def flash_table(property,
|
7
|
-
|
8
|
-
$ie.table(property.intern,propertyvalue).flash
|
9
|
+
def flash_table(browser_handle, property, property_value)
|
10
|
+
browser_handle.table(property.intern, /#{property_value}/).flash
|
9
11
|
end
|
10
12
|
|
11
13
|
#Check whether a table exists or not.
|
12
|
-
def exists_table(property,
|
13
|
-
|
14
|
-
$ie.table(property.intern,propertyvalue).exists?
|
14
|
+
def exists_table?(browser_handle, property, property_value)
|
15
|
+
browser_handle.table(property.intern, /#{property_value}/).exists?
|
15
16
|
end
|
16
17
|
|
17
|
-
#
|
18
|
-
def
|
19
|
-
|
20
|
-
$ie.table(property.intern,propertyvalue).to_a
|
18
|
+
#Get the table contents.
|
19
|
+
def get_table_contents(browser_handle, property, property_value)
|
20
|
+
browser_handle.table(property.intern, /#{property_value}/).to_a
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -1,51 +1,43 @@
|
|
1
|
-
|
1
|
+
#******************************************************
|
2
|
+
#TextField methods
|
3
|
+
#******************************************************
|
4
|
+
require File.expand_path('common_helpers', File.dirname(__FILE__))
|
2
5
|
|
3
6
|
module TextFieldHelper
|
4
7
|
|
5
8
|
#Set a texfield with a text.
|
6
|
-
def set_textfield(property,
|
7
|
-
|
8
|
-
$ie.text_field(property.intern,propertyvalue).set settextvalue
|
9
|
+
def set_textfield(browser_handle, property, property_value, settextvalue)
|
10
|
+
browser_handle.text_field(property.intern, /#{property_value}/).set settextvalue.to_s
|
9
11
|
end
|
10
12
|
|
11
13
|
#Get the text from the textfield.
|
12
|
-
def
|
13
|
-
|
14
|
-
return nil
|
15
|
-
else
|
16
|
-
return $settext
|
17
|
-
end
|
14
|
+
def get_textfield_contents(browser_handle, property, property_value)
|
15
|
+
browser_handle.text_field(property.intern, /#{property_value}/).value
|
18
16
|
end
|
19
17
|
|
20
18
|
#Clear a texfield.
|
21
|
-
def clear_textfield(property,
|
22
|
-
|
23
|
-
|
19
|
+
def clear_textfield(browser_handle, property, property_value)
|
20
|
+
browser_handle.text_field(property.intern, /#{property_value}/).clear
|
21
|
+
end
|
22
|
+
|
23
|
+
#TextField contains a value or not
|
24
|
+
def textfield_contains_value?(browser_handle, property, property_value, val)
|
25
|
+
get_textfield_contents(browser_handle, property, property_value) == val ? true : false
|
24
26
|
end
|
25
27
|
|
26
28
|
#Highlight or Flash a textfield.
|
27
|
-
def flash_textfield(property,
|
28
|
-
|
29
|
-
$ie.text_field(property.intern,propertyvalue).flash
|
29
|
+
def flash_textfield(browser_handle, property, property_value)
|
30
|
+
browser_handle.text_field(property.intern, /#{property_value}/).flash
|
30
31
|
end
|
31
32
|
|
32
33
|
#Check whether a textfield exists or not.
|
33
|
-
def exists_textfield(property,
|
34
|
-
|
35
|
-
$ie.text_field(property.intern,propertyvalue).exists?
|
34
|
+
def exists_textfield?(browser_handle, property, property_value)
|
35
|
+
browser_handle.text_field(property.intern, /#{property_value}/).exists?
|
36
36
|
end
|
37
37
|
|
38
38
|
#Check whether a textfield is blank or not.
|
39
|
-
def is_blank_textfield()
|
40
|
-
|
41
|
-
end
|
42
|
-
|
39
|
+
def is_blank_textfield?(browser_handle, property, property_value)
|
40
|
+
[nil, ""].include?(get_textfield_contents(browser_handle, property, property_value)) ? true : false
|
43
41
|
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
end
|