selenium-cucumber 0.1.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/bin/generate.rb +20 -20
  3. data/bin/helper.rb +50 -50
  4. data/bin/selenium-cucumber +30 -29
  5. data/doc/canned_steps.md +8 -0
  6. data/doc/installation.md +16 -16
  7. data/doc/selenium-cucumber-help.md +18 -18
  8. data/example/Gemfile +5 -0
  9. data/example/Gemfile.lock +36 -0
  10. data/{Example/image_difference → example/features/actual_images}/test.png +0 -0
  11. data/{Example → example}/features/assertion_steps_Ex.feature +22 -10
  12. data/{Example → example}/features/click_steps_Ex.feature +0 -0
  13. data/{Example → example}/features/configuration_step_Ex.feature +1 -2
  14. data/example/features/expected_images/logo-PNG.png +0 -0
  15. data/example/features/expected_images/original_image.jpg +0 -0
  16. data/{Example/screenshots → example/features/image_difference}/test.png +0 -0
  17. data/{Example → example}/features/input_steps_Ex.feature +0 -0
  18. data/{Example → example}/features/javascript_steps_Ex.feature +0 -0
  19. data/{Example → example}/features/navigation_steps_Ex.feature +3 -3
  20. data/{Example → example}/features/progress_step_Ex.feature +0 -0
  21. data/{Example → example}/features/screenshot_step_Ex.feature +5 -1
  22. data/example/features/screenshots/test.png +0 -0
  23. data/{Example → example}/features/step_definitions/custom_steps.rb +0 -0
  24. data/{Example → example}/features/support/env.rb +0 -1
  25. data/{Example → example}/features/support/hooks.rb +0 -0
  26. data/example/run_features.rb +42 -0
  27. data/example/test_page.html +218 -0
  28. data/features-skeleton/actual_images/test.png +0 -0
  29. data/features-skeleton/my_first.feature +5 -5
  30. data/features-skeleton/step_definitions/custom_steps.rb +4 -4
  31. data/features-skeleton/support/env.rb +38 -38
  32. data/features-skeleton/support/hooks.rb +37 -33
  33. data/lib/selenium-cucumber.rb +2 -2
  34. data/lib/selenium-cucumber/assertion_steps.rb +25 -27
  35. data/lib/selenium-cucumber/click_elements_steps.rb +9 -12
  36. data/lib/selenium-cucumber/configuration_steps.rb +3 -4
  37. data/lib/selenium-cucumber/input_steps.rb +26 -26
  38. data/lib/selenium-cucumber/javascript_handling_steps.rb +3 -3
  39. data/lib/selenium-cucumber/methods/assertion_methods.rb +197 -160
  40. data/lib/selenium-cucumber/methods/click_elements_methods.rb +8 -8
  41. data/lib/selenium-cucumber/methods/configuration_methods.rb +10 -5
  42. data/lib/selenium-cucumber/methods/input_methods.rb +32 -45
  43. data/lib/selenium-cucumber/methods/javascript_handling_methods.rb +7 -7
  44. data/lib/selenium-cucumber/methods/misc_methods.rb +6 -6
  45. data/lib/selenium-cucumber/methods/navigate_methods.rb +37 -41
  46. data/lib/selenium-cucumber/methods/progress_methods.rb +8 -8
  47. data/lib/selenium-cucumber/methods/required_files.rb +1 -1
  48. data/lib/selenium-cucumber/methods/screenshot_methods.rb +3 -3
  49. data/lib/selenium-cucumber/navigation_steps.rb +20 -22
  50. data/lib/selenium-cucumber/progress_steps.rb +5 -8
  51. data/lib/selenium-cucumber/screenshot_steps.rb +2 -2
  52. data/lib/selenium-cucumber/version.rb +1 -1
  53. metadata +23 -27
  54. data/Example/expected_images/flower.png +0 -0
  55. data/Example/expected_images/flower1.png +0 -0
  56. data/Example/features/new.feature +0 -7
  57. data/Example/image_difference/difference_20140814210820942.png +0 -0
  58. data/Example/image_difference/difference_20140815095331224.png +0 -0
  59. data/Example/image_difference/difference_20140815100021133.png +0 -0
  60. data/Example/image_difference/difference_20140815100348774.png +0 -0
  61. data/Example/run_features.rb +0 -42
  62. data/Example/screenshots/screenshot20140815095553337.png +0 -0
  63. data/Example/screenshots/screenshot20140815100120197.png +0 -0
  64. data/Example/screenshots/screenshot20140815100446914.png +0 -0
  65. data/Example/test_page.html +0 -206
@@ -31,7 +31,6 @@ end
31
31
  begin
32
32
  $driver = Selenium::WebDriver.for(browser_type)
33
33
  $driver.manage().window().maximize()
34
-
35
34
  rescue Exception => e
36
35
  puts e.message
37
36
  end
File without changes
@@ -0,0 +1,42 @@
1
+ require 'selenium-webdriver'
2
+
3
+ puts ARGV[0]
4
+
5
+ OS = Selenium::WebDriver::Platform.os
6
+
7
+ if ARGV.length == 0
8
+
9
+ puts "\n\n\t###### Running all features on firefox browser ######\n\n"
10
+ system('cucumber')
11
+
12
+ puts "\n\n\t###### Running all features on chrome browser ###### \n\n"
13
+ system('cucumber BROWSER=chrome')
14
+
15
+ if OS.to_s == 'windows'
16
+ puts "Running all features on internet explorer browser ###### \n\n"
17
+ system('cucumber BROWSER=ie')
18
+ elsif OS.to_s == 'mac'
19
+ puts "Running all features on safari browser ###### \n\n"
20
+ system('cucumber BROWSER=safari')
21
+ end
22
+
23
+ elsif ARGV.shift == 'html'
24
+
25
+ puts "\n\n\t###### Running all features on firefox browser ###### \n\n"
26
+ puts "Output result stored in \"result_firefox.html\""
27
+ system('cucumber -f html -o result_firefox.html')
28
+
29
+ puts "\n\n\t###### Running all features on chrome browser ###### \n\n"
30
+ puts "Output result stored in \"result_chrome.html\""
31
+ system('cucumber BROWSER=chrome -f html -o result_chrome.html')
32
+
33
+ if OS.to_s == 'windows'
34
+ puts "\n\n\t###### Running all features on internet explorer browser ###### \n\n"
35
+ puts "Output result stored in \"result_ie.html\""
36
+ system('cucumber BROWSER=ie -f html -o result_ie.html')
37
+ elsif OS.to_s == 'mac'
38
+ puts "\n\n\t###### Running all features on safari browser ###### \n\n"
39
+ puts "Output result stored in \"result_safari.html\""
40
+ system('cucumber BROWSER=safari -f html -o result_safari.html')
41
+ end
42
+ end
@@ -0,0 +1,218 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <title>Test Page for selenium-cucumber</title>
6
+
7
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
8
+ <script type="text/javascript">
9
+ $(function() {
10
+ $("#hiddenElement").hide();
11
+
12
+ setTimeout(function() {
13
+ $("#hiddenElement").fadeIn(1500);
14
+ }, 10000);
15
+
16
+ setTimeout(function() {
17
+ $("#disabledBt").removeAttr("disabled");
18
+ }, 20000);
19
+ });
20
+ </script>
21
+
22
+ <style>
23
+ a:hover{
24
+ background-color: yellow;
25
+ }
26
+ </style>
27
+ </head>
28
+ <body>
29
+ <script>
30
+ function showText() {
31
+ document.getElementById("msg").innerHTML = "Now button is enabled";
32
+ }
33
+
34
+ function callAlert() {
35
+ var x;
36
+ if (confirm("Press a button!") == true) {
37
+ x = "You pressed OK!";
38
+ } else {
39
+ x = "You pressed Cancel!";
40
+ }
41
+ document.getElementById("demo").innerHTML = x;
42
+ }
43
+
44
+ function doubleClick() {
45
+ document.getElementById("demo2").innerHTML = "Hello World";
46
+ }
47
+
48
+ function hovered() {
49
+ alert("Mouse hovered")
50
+ }
51
+ </script>
52
+ <form id="frm" action="" method="post">
53
+ <fieldset>
54
+ <legend class="form_name">Simple sample form with input elements</legend>
55
+ <p>
56
+ <label for="dummy0">Text input (first name)</label><br>
57
+ <input type="text" class="fname_class" name="fname_name" id="f_name" value="">
58
+ </p>
59
+
60
+ <p>
61
+ <label for="dummy1">Text input (last name)</label><br>
62
+ <input type="text" class="lname_class" id="l_name" name="lname_name" value="">
63
+ </p>
64
+
65
+ <p>
66
+ <label for="dummy1">Disabled field</label><br>
67
+ <input type="text" class="df_class" id="df_id" name="df_name" value="" disabled>
68
+ </p>
69
+
70
+ <p>
71
+ <label for="dummy2">Textarea (address)</label><br>
72
+ <textarea name="dummy2" id="address" class="address_class" rows="3" cols="20" value=""></textarea>
73
+ </p>
74
+
75
+ <p>
76
+ <label for="dummy3">A password field (password)</label><br>
77
+ <input type="password" class="cls_pwd" id="pwd" name="nm_pwd" value="">
78
+ </p>
79
+
80
+ <p>
81
+ <label for="dummy4">radio button group (Gender)</label><br>
82
+ <input type="radio" name="radio_gender" value="M">Male</input>
83
+ <input type="radio" name="radio_gender" value="F">Female</input>
84
+ </p>
85
+
86
+ <p>
87
+ <input type="submit" value="Submit" id="submit" name="btn_submit" >
88
+ <input type="reset" value="Reset" id="reset" name="btn_reset">
89
+ <input type="button" value="disabledBt" id="disabledBt_id" name="disabledBt_name" disabled>
90
+ </p>
91
+ </fieldset>
92
+ </form>
93
+
94
+ <br>
95
+
96
+ <fieldset>
97
+ <legend>Multiselect dropdown</legend>
98
+ <p>
99
+ <select name="cars" multiple>
100
+ <option value="volvo">Volvo</option>
101
+ <option value="saab">Saab</option>
102
+ <option value="opel">Opel</option>
103
+ <option value="audi">Audi</option>
104
+ </select>
105
+ </p>
106
+ </fieldset>
107
+
108
+ <br>
109
+
110
+ <fieldset>
111
+ <legend>Dropdown lists</legend>
112
+ <p>
113
+ <label for="dummy3">Select field</label><br>
114
+ <select id="dropdownList1" name="name_select1" value="Please select your choice select">
115
+ <option value="s1">Select_1</option>
116
+ <option value="s2">Select_2</option>
117
+ <option value="s3" selected>Select_3</option>
118
+ <option value="s4">Select_4</option>
119
+ <option value="s5">Select_5</option>
120
+ </select>
121
+ </p>
122
+ </fieldset>
123
+
124
+ <br>
125
+
126
+ <fieldset>
127
+ <legend>Radio Buttons </legend>
128
+ <p>
129
+ <input type="radio" id="rdb1" name="rdb1_name" class="rdb1_class" checked> Radio one<br>
130
+ <input type="radio" id="rdb2" name="rdb2_name" class="rdb2_class"> Radio two<br>
131
+ <input type="radio" id="rdb3" name="rdb3_name" class="rdb3_class"> Radio three<br>
132
+ <input type="radio" id="rdb4" name="rdb4_name" class="rdb4_class"> Radio four<br>
133
+ <input type="radio" id="rdb5" name="rdb5_name" class="rdb5_class" checked> Radio five<br>
134
+ </p>
135
+ </fieldset>
136
+
137
+ <br>
138
+
139
+ <fieldset>
140
+ <legend>Checkbox </legend>
141
+ <p>
142
+ <input type="checkbox" id="chk1" name="chk1_name" class="chk1_class" checked> Check one<br>
143
+ <input type="checkbox" id="chk2" name="chk2_name" class="chk2_class"> Check two<br>
144
+ <input type="checkbox" id="chk3" name="chk3_name" class="chk3_class"> Check three<br>
145
+ <input type="checkbox" id="chk4" name="chk4_name" class="chk4_class"> Check four<br>
146
+ <input type="checkbox" id="chk5" name="chk5_name" class="chk5_class" checked> Check five<br>
147
+ </p>
148
+ </fieldset>
149
+
150
+ <br>
151
+
152
+ <fieldset>
153
+ <legend>Display element after 10 sec</legend>
154
+ <div id="hiddenElement" name="he_name" class="he_class">This showed after 10 sec</div>
155
+ </fieldset>
156
+
157
+ <br>
158
+
159
+ <fieldset>
160
+ <legend>Enable Button after 10 sec</legend>
161
+ <input type="button" value="Button" id="disabledBt" onclick="showText()" disabled>
162
+ <p id="msg"></p>
163
+ </fieldset>
164
+
165
+ <br>
166
+
167
+ <fieldset>
168
+ <legend>Images - valid</legend>
169
+ JPG image <img id="img1" src="http://s27.postimg.org/xlqzpviyr/original_image.jpg" alt="Image one">
170
+ PNG image <img id="img2" src="http://s26.postimg.org/itpfqlcop/logo1.png" alt="Image one">
171
+ </fieldset>
172
+
173
+ <br>
174
+
175
+ <fieldset>
176
+ <legend>Images - Invalid</legend>
177
+ JPG image <img id="img1_incorrect" src="http://s27.postimg.org/kkehri9c3/original_image.jpg" alt="Image one">
178
+ PNG image <img id="img2_incorrect" src="http://s28.postimg.org/kjqls15el/logo_incorrect.png" alt="Image one">
179
+ </fieldset>
180
+
181
+ <br>
182
+
183
+ <fieldset>
184
+ <legend>Links</legend>
185
+ <p>
186
+ <a href="https://rubygems.org/gems/selenium-cucumber">selenium-cucumber gem</a> <br>
187
+ <a href="http://seleniumcucumber.wordpress.com/" onclick="window.open('http://seleniumcucumber.wordpress.com/', 'newwindow', 'width=500, height=500'); return false;">selenium-cucumber website</a> <br>
188
+ <a href="https://github.com/sameer49/selenium-cucumber/blob/master/doc/canned_steps.md">Predefined-steps</a>
189
+ </p>
190
+ </fieldset>
191
+
192
+ <br>
193
+
194
+ <fieldset>
195
+ <legend>Mous hover</legend>
196
+ <button id="pop_alert" onmouseover="hovered()">Hover It</button>
197
+ </fieldset>
198
+
199
+ <br>
200
+
201
+ <fieldset>
202
+ <legend>Javascript alert</legend>
203
+ <p name="javascript_alert_msg">Click the button to display a confirm box.</p>
204
+ <button id="try_it" onclick="callAlert()">Try it</button>
205
+ <p id="demo">this is demo line</p>
206
+ </p>
207
+ </fieldset>
208
+
209
+ <br>
210
+
211
+ <fieldset>
212
+ <legend>Double click here</legend>
213
+ <p id="dbClick" ondblclick="doubleClick()">Double-click this paragraph to trigger a function.</p>
214
+ <p id="demo2" name="demo2_name"></p>
215
+ </p>
216
+ </fieldset>
217
+ </body>
218
+ </html>
@@ -1,5 +1,5 @@
1
- Feature: Login feature
2
-
3
- Scenario: As a valid user I can log into my web app
4
- When I press "Login"
5
- Then I see "Welcome to coolest web app ever"
1
+ Feature: Login feature
2
+
3
+ Scenario: As a valid user I can log into my web app
4
+ When I press "Login"
5
+ Then I see "Welcome to coolest web app ever"
@@ -1,5 +1,5 @@
1
- require 'selenium-cucumber'
2
-
3
- # Do Not Remove This File
4
- # Add your custom steps here
1
+ require 'selenium-cucumber'
2
+
3
+ # Do Not Remove This File
4
+ # Add your custom steps here
5
5
  # $driver is instance of webdriver use this instance to write your custom code
@@ -1,38 +1,38 @@
1
- require 'rubygems'
2
- require 'selenium-webdriver'
3
-
4
- def print_error
5
- puts "\nInappropraite browser \"#{ENV['BROWSER']}\""
6
- puts "\nUsage : cucumber BROWSER=browser_name"
7
- puts "\nbrowser_name can be one of following :"
8
- puts "1.ie\n2.chrome\n3.ff\n4.safari\n5.opera"
9
- puts "\nNow using default browser \"Firefox\""
10
- end
11
-
12
- case ENV['BROWSER']
13
- when 'ie'
14
- browser_type = :ie
15
- when 'ff'
16
- browser_type = :ff
17
- when 'chrome'
18
- browser_type = :chrome
19
- when 'opera'
20
- browser_type = :opera
21
- when 'safari'
22
- browser_type = :safari
23
- else
24
- if ENV['BROWSER']
25
- print_error
26
- end
27
- browser_type = :ff
28
- end
29
-
30
-
31
- begin
32
- $driver = Selenium::WebDriver.for(browser_type)
33
- $driver.manage().window().maximize()
34
-
35
- rescue Exception => e
36
- puts e.message
37
- end
38
-
1
+ require 'rubygems'
2
+ require 'selenium-webdriver'
3
+
4
+ def print_error
5
+ puts "\nInappropraite browser \"#{ENV['BROWSER']}\""
6
+ puts "\nUsage : cucumber BROWSER=browser_name"
7
+ puts "\nbrowser_name can be one of following :"
8
+ puts "1.ie\n2.chrome\n3.ff\n4.safari\n5.opera"
9
+ puts "\nNow using default browser \"Firefox\""
10
+ end
11
+
12
+ case ENV['BROWSER']
13
+ when 'ie'
14
+ browser_type = :ie
15
+ when 'ff'
16
+ browser_type = :ff
17
+ when 'chrome'
18
+ browser_type = :chrome
19
+ when 'opera'
20
+ browser_type = :opera
21
+ when 'safari'
22
+ browser_type = :safari
23
+ else
24
+ if ENV['BROWSER']
25
+ print_error
26
+ end
27
+ browser_type = :ff
28
+ end
29
+
30
+
31
+ begin
32
+ $driver = Selenium::WebDriver.for(browser_type)
33
+ $driver.manage().window().maximize()
34
+
35
+ rescue Exception => e
36
+ puts e.message
37
+ end
38
+
@@ -1,34 +1,38 @@
1
- #Cucumber provides a number of hooks which allow us to run blocks at various points in the Cucumber test cycle
2
-
3
- Before do
4
- # Do something before each scenario.
5
- end
6
-
7
- Before do |scenario|
8
- # The +scenario+ argument is optional, but if you use it, you can get the title,
9
- # description, or name (title + description) of the scenario that is about to be
10
- # executed.
11
- end
12
-
13
- After do |scenario|
14
- # Do something after each scenario.
15
- # The +scenario+ argument is optional, but
16
- # if you use it, you can inspect status with
17
- # the #failed?, #passed? and #exception methods.
18
-
19
- if(scenario.failed?)
20
- #Do something if scenario fails.
21
- end
22
- end
23
-
24
- #Tagged hooks
25
-
26
- Before('@Ex_tag1, @Ex_tag2') do
27
- # This will only run before scenarios tagged
28
- # with @cucumis OR @sativus.
29
- end
30
-
31
- AfterStep('@Ex_tag1, @Ex_tag2') do
32
- # This will only run after steps within scenarios tagged
33
- # with @cucumis AND @sativus.
1
+ #Cucumber provides a number of hooks which allow us to run blocks at various points in the Cucumber test cycle
2
+
3
+ Before do
4
+ # Do something before each scenario.
5
+ end
6
+
7
+ Before do |scenario|
8
+ # The +scenario+ argument is optional, but if you use it, you can get the title,
9
+ # description, or name (title + description) of the scenario that is about to be
10
+ # executed.
11
+ end
12
+
13
+ After do
14
+ # Do something after each scenario.
15
+ end
16
+
17
+ After do |scenario|
18
+ # Do something after each scenario.
19
+ # The +scenario+ argument is optional, but
20
+ # if you use it, you can inspect status with
21
+ # the #failed?, #passed? and #exception methods.
22
+
23
+ if(scenario.failed?)
24
+ #Do something if scenario fails.
25
+ end
26
+ end
27
+
28
+ #Tagged hooks
29
+
30
+ Before('@Ex_tag1, @Ex_tag2') do
31
+ # This will only run before scenarios tagged
32
+ # with @cucumis OR @sativus.
33
+ end
34
+
35
+ AfterStep('@Ex_tag1, @Ex_tag2') do
36
+ # This will only run after steps within scenarios tagged
37
+ # with @cucumis AND @sativus.
34
38
  end