selenium-cucumber 1.1.2 → 2.1.2

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/doc/canned_steps.md +17 -0
  3. data/features-skeleton/support/env.rb +42 -29
  4. data/lib/selenium-cucumber.rb +0 -1
  5. data/lib/selenium-cucumber/assertion_steps.rb +6 -2
  6. data/lib/selenium-cucumber/click_elements_steps.rb +10 -0
  7. data/lib/selenium-cucumber/methods/assertion_methods.rb +78 -8
  8. data/lib/selenium-cucumber/methods/click_elements_methods.rb +8 -0
  9. data/lib/selenium-cucumber/methods/configuration_methods.rb +23 -2
  10. data/lib/selenium-cucumber/methods/error_handling_methods.rb +87 -0
  11. data/lib/selenium-cucumber/methods/misc_methods.rb +9 -0
  12. data/lib/selenium-cucumber/methods/navigate_methods.rb +5 -0
  13. data/lib/selenium-cucumber/methods/required_files.rb +2 -0
  14. data/lib/selenium-cucumber/navigation_steps.rb +4 -0
  15. data/lib/selenium-cucumber/version.rb +1 -1
  16. metadata +68 -51
  17. data/example/Gemfile +0 -5
  18. data/example/Gemfile.lock +0 -36
  19. data/example/features/actual_images/test.png +0 -0
  20. data/example/features/assertion_steps_Ex.feature +0 -149
  21. data/example/features/click_steps_Ex.feature +0 -28
  22. data/example/features/configuration_step_Ex.feature +0 -8
  23. data/example/features/expected_images/logo-PNG.png +0 -0
  24. data/example/features/expected_images/original_image.jpg +0 -0
  25. data/example/features/image_difference/test.png +0 -0
  26. data/example/features/input_steps_Ex.feature +0 -87
  27. data/example/features/javascript_steps_Ex.feature +0 -19
  28. data/example/features/navigation_steps_Ex.feature +0 -45
  29. data/example/features/new.feature +0 -17
  30. data/example/features/progress_step_Ex.feature +0 -18
  31. data/example/features/screenshot_step_Ex.feature +0 -12
  32. data/example/features/screenshots/test.png +0 -0
  33. data/example/features/step_definitions/custom_steps.rb +0 -14
  34. data/example/features/support/env.rb +0 -37
  35. data/example/features/support/hooks.rb +0 -34
  36. data/example/run_features.rb +0 -42
  37. data/example/test_page.html +0 -224
@@ -1,28 +0,0 @@
1
-
2
- Feature: Click On Elements
3
- As a user I should able to click on elements
4
-
5
- Scenario: Open test page
6
-
7
- Given I open test page
8
-
9
- Scenario: click on elements
10
-
11
- Then I enter "selenium-cucumber" into input field having id "f_name"
12
- Then I click on element having id "reset"
13
- Then element having id "f_name" should have attribute "value" with value ""
14
-
15
- Scenario: double click on elements
16
-
17
- Then I double click on element having id "dbClick"
18
- Then element having name "demo2_name" should be present
19
-
20
- Scenario: click on links having text
21
-
22
- Then I click on link having text "selenium-cucumber gem"
23
- Then I should see page title as "selenium-cucumber | RubyGems.org | your community gem host"
24
-
25
- Scenario: click on links having partial text
26
-
27
- Then I click on link having partial text "Home"
28
- Then I should see page title as "Selenium-Cucumber | Code Less… Test More…"
@@ -1,8 +0,0 @@
1
-
2
- Feature: Configuration Printing Step
3
- As a user I should able to print configuration
4
-
5
- Scenario: Print Configuration
6
-
7
- Given I print configuration
8
- And I open test page
@@ -1,87 +0,0 @@
1
-
2
- Feature: Input Step
3
- As a user I should able to give inputs
4
-
5
- Scenario: Open test page
6
-
7
- Given I open test page
8
-
9
- Scenario: Enter text into textfield
10
-
11
- Then I enter "abc" into input field having id "f_name"
12
- Then element having id "f_name" should have attribute "value" with value "abc"
13
-
14
- Then I enter "xyz" into input field having name "lname_name"
15
- Then element having name "lname_name" should have attribute "value" with value "xyz"
16
-
17
- Then I enter "pqr" into input field having class "address_class"
18
- Then element having class "address_class" should have attribute "value" with value "pqr"
19
-
20
-
21
- Scenario: Clear text From textfield
22
-
23
- Then I clear input field having id "f_name"
24
- Then element having id "f_name" should have attribute "value" with value ""
25
-
26
- Then I clear input field having name "lname_name"
27
- Then element having name "lname_name" should have attribute "value" with value ""
28
-
29
- Then I clear input field having class "address_class"
30
- Then element having class "address_class" should have attribute "value" with value ""
31
-
32
- Scenario: select option from dropdown list
33
-
34
- Then I select "Select_5" option by text from dropdown having id "dropdownList1"
35
- Then option "Select_5" by text from dropdown having id "dropdownList1" should be selected
36
-
37
- Then I select 1 option by index from dropdown having id "dropdownList1"
38
- Then option "Select_1" by text from dropdown having id "dropdownList1" should be selected
39
-
40
- Then I select "s3" option by value from dropdown having id "dropdownList1"
41
- Then option "s3" by value from dropdown having id "dropdownList1" should be selected
42
-
43
- Scenario: select option from Multiselect List
44
-
45
- Then I select "Volvo" option by text from multiselect dropdown having name "cars"
46
- Then I select 4 option by index from multiselect dropdown having name "cars"
47
- Then I select "opel" option by value from multiselect dropdown having name "cars"
48
-
49
- Scenario: unselect all options from Multiselect List
50
-
51
- Then I unselect all options from multiselect dropdown having name "cars"
52
-
53
- Scenario: select all options from Multiselect List
54
-
55
- Then I select all options from multiselect dropdown having name "cars"
56
-
57
- Scenario: selecting checkbox
58
-
59
- Then I check the checkbox having id "chk3"
60
- Then checkbox having id "chk3" should be checked
61
-
62
- Then I check the checkbox having name "chk2_name"
63
- Then checkbox having name "chk2_name" should be checked
64
-
65
- Scenario: unselecting checkbox
66
-
67
- Then I uncheck the checkbox having class "chk5_class"
68
- Then checkbox having class "chk5_class" should be unchecked
69
-
70
- Scenario: toggle checkbox
71
-
72
- Then I toggle checkbox having id "chk4"
73
- Then checkbox having id "chk4" should be checked
74
-
75
- Then I toggle checkbox having id "chk4"
76
- Then checkbox having id "chk4" should be unchecked
77
-
78
- Scenario: selecting radio buttons
79
-
80
- Then I select radio button having id "rdb2"
81
- Then radio button having id "rdb2" should be selected
82
-
83
- Then I select radio button having name "rdb3_name"
84
- Then radio button having name "rdb3_name" should be selected
85
-
86
- Then I select radio button having class "rdb4_class"
87
- Then radio button having class "rdb4_class" should be selected
@@ -1,19 +0,0 @@
1
-
2
- Feature: Javasciprt Handling Steps
3
- As a user I should able to handle javascript pop-up
4
-
5
- Scenario: Open test page
6
- Given I open test page
7
-
8
- Scenario: accept alert
9
-
10
- Then I click on element having id "try_it"
11
- Then I accept alert
12
- Then element having id "demo" should have text as "You pressed OK!"
13
-
14
- Scenario: dismiss alert
15
-
16
- Then I click on element having id "try_it"
17
- Then I dismiss alert
18
- Then element having id "demo" should have text as "You pressed Cancel!"
19
-
@@ -1,45 +0,0 @@
1
- Feature: Navigation Steps
2
- As a user I should able to navigate on web page
3
-
4
- Scenario: Open test page
5
- Given I open test page
6
-
7
- Scenario: navigating back/forward and refresh page
8
-
9
- Then I click on link having text "selenium-cucumber gem"
10
- Then I should see page title as "selenium-cucumber | RubyGems.org | your community gem host"
11
-
12
- Then I navigate back
13
- Then I should see page title as "Test Page for selenium-cucumber"
14
-
15
- Then I navigate forward
16
- Then I should see page title as "selenium-cucumber | RubyGems.org | your community gem host"
17
-
18
- Then I navigate back
19
- Then I should see page title as "Test Page for selenium-cucumber"
20
-
21
- Then I refresh page
22
- Then I should see page title as "Test Page for selenium-cucumber"
23
-
24
-
25
- Scenario: Zoom in/out web page
26
-
27
- Then I zoom in page
28
- Then I zoom out page
29
- Then I reset page view
30
-
31
- Scenario: Scroll web page
32
-
33
- Then I scroll to element having id "demo"
34
- Then I scroll to top of page
35
- Then I scroll to end of page
36
-
37
- Scenario: Hover over elelment
38
-
39
- Then I hover over element having id "pop_alert"
40
- Then I accept alert
41
-
42
- Scenario: Interacting with browser
43
-
44
- Then I resize browser window size to width 400 and height 400
45
- Then I maximize browser window
@@ -1,17 +0,0 @@
1
-
2
- Feature: click steps
3
- As a user I should able to verify using assert steps
4
-
5
- Scenario: Open test page
6
- Given I open test page
7
-
8
- Scenario: click on link
9
-
10
- Then I click on link having text "video tutorials"
11
-
12
- Scenario: click on link
13
-
14
- Then I click on link having text "blog"
15
-
16
- Scenario: switch to new window
17
- Then I switch to new window
@@ -1,18 +0,0 @@
1
-
2
- Feature: Progress Steps
3
- As a user I should able to wait
4
-
5
- Scenario: Open test page
6
- Given I open test page
7
-
8
- Scenario: wait for elements to display
9
-
10
- Then element having id "hiddenElement" should not be present
11
- Then I wait 15 seconds for element having id "hiddenElement" to display
12
- Then element having id "hiddenElement" should be present
13
-
14
- Scenario: wait for elements to enabled
15
-
16
- Then element having id "disabledBt" should be disabled
17
- Then I wait 15 seconds for element having id "disabledBt" to enable
18
- Then element having id "disabledBt" should be enabled
@@ -1,12 +0,0 @@
1
- Feature: Screenshot Step
2
- As a user I should able to take screenshot
3
-
4
- Scenario: Open test page
5
- Given I open test page
6
-
7
- Scenario: take screenshot
8
- Then I take screenshot
9
-
10
- Scenario: close browser
11
- Then I close browser
12
-
@@ -1,14 +0,0 @@
1
- require 'selenium-cucumber'
2
-
3
- # Do Not Remove This File
4
- # Add your custom steps here
5
- # $driver is instance of webdriver use this instance to write your custom code
6
-
7
-
8
-
9
- Given(/^I open test page$/) do
10
- link = 'file:///'
11
- link+= File.absolute_path("test_page.html")
12
- navigate_to(link)
13
- end
14
-
@@ -1,37 +0,0 @@
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
- rescue Exception => e
35
- puts e.message
36
- end
37
-
@@ -1,34 +0,0 @@
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.
34
- end
@@ -1,42 +0,0 @@
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
@@ -1,224 +0,0 @@
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
-
188
- <a href="https://github.com/sameer49/selenium-cucumber/blob/master/doc/canned_steps.md">Predefined-steps</a><br>
189
-
190
- <a href="http://seleniumcucumber.info/" onclick="window.open('http://seleniumcucumber.info/', 'newwindow', 'width=500, height=500'); return false;">selenium-cucumber website</a> <br>
191
-
192
- <a href="http://seleniumcucumber.info/video-tutorials/" target="_blank">video tutorials</a> <br>
193
-
194
- <a href="http://seleniumcucumber.info/blog/" target="_blank">blog</a> <br>
195
- </p>
196
- </fieldset>
197
-
198
- <br>
199
-
200
- <fieldset>
201
- <legend>Mous hover</legend>
202
- <button id="pop_alert" onmouseover="hovered()">Hover It</button>
203
- </fieldset>
204
-
205
- <br>
206
-
207
- <fieldset>
208
- <legend>Javascript alert</legend>
209
- <p name="javascript_alert_msg">Click the button to display a confirm box.</p>
210
- <button id="try_it" onclick="callAlert()">Try it</button>
211
- <p id="demo">this is demo line</p>
212
- </p>
213
- </fieldset>
214
-
215
- <br>
216
-
217
- <fieldset>
218
- <legend>Double click here</legend>
219
- <p id="dbClick" ondblclick="doubleClick()">Double-click this paragraph to trigger a function.</p>
220
- <p id="demo2" name="demo2_name"></p>
221
- </p>
222
- </fieldset>
223
- </body>
224
- </html>