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.
@@ -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 Utility:
1
+ About this gem:
2
2
 
3
- This is a utility(watir_helper) developed for making Automation Testing faster, simpler and easier through WATIR.
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. No need to create an IE Instance.
8
+ 1. Freedom to choose the browser. Right now this gem is only tested with IE.
8
9
 
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")
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
- # set_texfield("name","q","Ruby")
16
+ # ie1 = set_browser("ie")
14
17
 
15
- # click_button("name","btnG")
18
+ # goto_page(ie1, "http://www.google.com/")
19
+
20
+ # close_browser(ie1)
16
21
 
17
- # verify_text("Ruby")
22
+ # ie2 = set_browser("ie")
23
+
24
+ # goto_page(ie2, "http://rubygems.com/")
18
25
 
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
+ # 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
- Now, You can easily handle pop-up's.
34
+ # click_ok_js_popup("File Download")
36
35
 
37
- 6. Can add functions into this gem as WATIR is an Open Source tool.
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: http://ruby-lang.org
45
+ Install Ruby:
43
46
 
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
-
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
- gem install rspec -v 1.1.3 (This version is also needed because of some compatibility issue)
72
-
73
-
74
-
75
- Install rake:
58
+ Install rake :
76
59
 
77
- gem install rake
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
- Install IE Devleoper Toolbar from the site
66
+ How To Use:
82
67
 
83
- http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en
68
+ This only works on Windows. Requires Internet Explorer 5.5 or newer.
84
69
 
85
- How
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
- # include my utility(watir_helper)
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
- # 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/")
81
+ goto_page(ie, "http://www.google.com/")
101
82
 
102
- # print Title
83
+ # Display title of the current browser page
103
84
 
104
- puts get_title
85
+ puts get_title(ie)
105
86
 
106
- # print Url
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
- .
@@ -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
- require 'watir_helper/common_helpers'
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
- $ie.goto(url)
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
- $ie.forward
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
- $ie.back
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
- $ie.refresh
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
- $ie.title
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
- $ie.url
40
+ def get_url(browser_handle)
41
+ browser_handle.url
39
42
  end
40
43
 
41
- #Attach an IE instance.
42
- def attach_an_IE_window(property,propertyvalue)
43
- propertyvalue=/#{propertyvalue}/
44
- $ie=Watir::IE.attach(property.intern,propertyvalue)
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
- $ie.minimize
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
- $ie.maximize
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
- $ie.text.include?(text)
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
- require 'watir_helper/common_helpers'
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,propertyvalue)
7
- propertyvalue=/#{propertyvalue}/
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,propertyvalue)
13
- propertyvalue=/#{propertyvalue}/
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,propertyvalue)
19
- propertyvalue=/#{propertyvalue}/
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 ,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")
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,propertyvalue)
31
- propertyvalue=/#{propertyvalue}/
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,propertyvalue)
37
- propertyvalue=/#{propertyvalue}/
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
- require 'watir_helper/common_helpers'
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,propertyvalue)
7
- propertyvalue=/#{propertyvalue}/
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,propertyvalue)
13
- propertyvalue=/#{propertyvalue}/
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,propertyvalue)
19
- propertyvalue=/#{propertyvalue}/
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,propertyvalue)
25
- propertyvalue=/#{propertyvalue}/
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 is_checked_checkbox(property,propertyvalue)
31
- propertyvalue=/#{propertyvalue}/
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