selenium-cucumber 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/Example/features/assertion_steps_Ex.feature +121 -0
  2. data/Example/features/click_steps_Ex.feature +28 -0
  3. data/Example/features/configuration_step_Ex.feature +9 -0
  4. data/Example/features/input_steps_Ex.feature +87 -0
  5. data/Example/features/javascript_steps_Ex.feature +19 -0
  6. data/Example/features/navigation_steps_Ex.feature +45 -0
  7. data/Example/features/new.feature +7 -0
  8. data/Example/features/progress_step_Ex.feature +18 -0
  9. data/Example/features/screenshot_step_Ex.feature +11 -0
  10. data/Example/features/step_definitions/custom_steps.rb +14 -0
  11. data/Example/features/support/env.rb +38 -0
  12. data/Example/features/support/hooks.rb +34 -0
  13. data/Example/run_features.rb +40 -0
  14. data/Example/test_page.html +206 -0
  15. data/bin/generate.rb +20 -20
  16. data/bin/helper.rb +50 -50
  17. data/bin/selenium-cucumber +26 -26
  18. data/doc/canned_steps.md +479 -463
  19. data/doc/installation.md +16 -16
  20. data/doc/selenium-cucumber-API.md +81 -81
  21. data/doc/selenium-cucumber-help.md +18 -18
  22. data/features-skeleton/my_first.feature +5 -5
  23. data/features-skeleton/step_definitions/custom_steps.rb +4 -4
  24. data/features-skeleton/support/env.rb +38 -38
  25. data/features-skeleton/support/hooks.rb +33 -33
  26. data/lib/selenium-cucumber.rb +2 -2
  27. data/lib/selenium-cucumber/assertion_steps.rb +7 -2
  28. data/lib/selenium-cucumber/click_elements_steps.rb +7 -0
  29. data/lib/selenium-cucumber/methods/assertion_methods.rb +74 -24
  30. data/lib/selenium-cucumber/methods/click_elements_methods.rb +7 -2
  31. data/lib/selenium-cucumber/methods/configuration_methods.rb +1 -0
  32. data/lib/selenium-cucumber/methods/navigate_methods.rb +22 -32
  33. data/lib/selenium-cucumber/methods/required_files.rb +2 -0
  34. data/lib/selenium-cucumber/navigation_steps.rb +8 -0
  35. data/lib/selenium-cucumber/progress_steps.rb +2 -2
  36. data/lib/selenium-cucumber/version.rb +1 -1
  37. metadata +27 -45
@@ -0,0 +1,121 @@
1
+
2
+ Feature: Assertion 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: verify page title
9
+ Then I should see page title as "Test Page for selenium-cucumber"
10
+
11
+
12
+ Scenario: verify element text
13
+
14
+ Then element having id "dbClick" should have text as "Double-click this paragraph to trigger a function."
15
+ Then element having name "javascript_alert_msg" should have text as "Click the button to display a confirm box."
16
+ Then element having class "form_name" should have text as "Simple sample form with input elements"
17
+ Then element having xpath ".//*[@id='frm']/fieldset/p[1]/label" should have text as "Text input (first name)"
18
+
19
+ Then element having id "dbClick" should not have text as "Double-click this"
20
+ Then element having name "javascript_alert_msg" should not have text as "Click the button"
21
+ Then element having class "form_name" should not have text as "Simple sample"
22
+ Then element having xpath ".//*[@id='frm']/fieldset/p[3]/label" should not have text as "xyz"
23
+
24
+ Scenario: verify element text - negative test 1
25
+
26
+ Then element having id "dbClick" should have text as "Double-click this"
27
+
28
+ Scenario: verify element text - negative test 2
29
+
30
+ Then element having name "javascript_alert_msg" should not have text as "Click the button to display a confirm box."
31
+
32
+ Scenario: verify element accesibility
33
+
34
+ Then element having id "submit" should be enabled
35
+ Then element having name "btn_reset" should be enabled
36
+ Then element having class "cls_pwd" should be enabled
37
+ Then element having xpath ".//*[@id='try_it']" should be enabled
38
+
39
+ Then element having id "disabledBt_id" should be disabled
40
+ Then element having name "disabledBt_name" should be disabled
41
+ Then element having class "df_class" should be disabled
42
+ Then element having xpath ".//*[@id='df_id']" should be disabled
43
+
44
+ Scenario: verify element accesibility - negative test 1
45
+
46
+ Then element having id "submit" should be disabled
47
+
48
+ Scenario: verify element accesibility - negative test 2
49
+
50
+ Then element having id "disabledBt_id" should be enabled
51
+
52
+ Scenario: verify element visibility
53
+
54
+ Then element having id "hiddenElement" should not be present
55
+ Then element having name "he_name" should not be present
56
+ Then element having class "he_class" should not be present
57
+ Then element having xpath ".//*[@id='hiddenElement']" should not be present
58
+
59
+ And I wait for 10 sec
60
+
61
+ Then element having id "hiddenElement" should be present
62
+ Then element having name "he_name" should be present
63
+ Then element having class "he_class" should be present
64
+ Then element having xpath ".//*[@id='hiddenElement']" should be present
65
+
66
+ Scenario: verify checkbox checked or not
67
+
68
+ Then checkbox having id "chk1" should be checked
69
+ Then checkbox having name "chk5_name" should be checked
70
+ Then checkbox having xpath ".//*[@id='chk1']" should be checked
71
+ Then checkbox having class "chk5_class" should be checked
72
+
73
+ Then checkbox having id "chk2" should be unchecked
74
+ Then checkbox having name "chk3_name" should be unchecked
75
+ Then checkbox having class "chk4_class" should be unchecked
76
+
77
+ Scenario: verify checkbox checked or not - negative test 1
78
+
79
+ Then checkbox having class "chk3_class" should be checked
80
+
81
+ Scenario: verify checkbox checked or not - negative test 2
82
+
83
+ Then checkbox having class "chk5_class" should be unchecked
84
+
85
+ Scenario: verify radio button selected or not
86
+
87
+ Then radio button having id "rdb1" should be selected
88
+ Then radio button having id "rdb2" should be unselected
89
+
90
+ Scenario: verify radio button selected or not - negative test 1
91
+
92
+ Then radio button having id "rdb2" should be selected
93
+
94
+ Scenario: verify radio button selected or not - negative test 2
95
+
96
+ Then radio button having id "rdb1" should be unselected
97
+
98
+ Scenario: verify link present or not
99
+
100
+ Then link having text "selenium-cucumber gem" should be present
101
+ Then link having text "xyz" should not be present
102
+
103
+ Scenario: verify pop-up alert text
104
+
105
+ When I click on element having id "try_it"
106
+ Then I should see alert text as "Press a button!"
107
+ Then I accept alert
108
+
109
+ Scenario: verify image by id
110
+ Then actual image having id "img1" and expected image having id "img1" should be similar
111
+
112
+ Scenario: verify image by xpath
113
+ Then actual image having xpath ".//*[@id='img1']" and expected image having xpath ".//*[@id='img1']" should be similar
114
+
115
+ Scenario: verify image by id and path - negative test 1
116
+ Then actual image having id "img1" and expected image having path "C:/dropshadow-flower-pink.png" should be similar
117
+
118
+ Scenario: verify image by path - negative test 2
119
+ Then actual image having path "http://shared.ooyala.com.s3.amazonaws.com/dropshadow-flower-pink.png" and expected image having path "C:/dropshadow-flower-pink.png" should be similar
120
+
121
+
@@ -0,0 +1,28 @@
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…"
@@ -0,0 +1,9 @@
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
+ Given I open test page
9
+
@@ -0,0 +1,87 @@
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
@@ -0,0 +1,19 @@
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
+
@@ -0,0 +1,45 @@
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 xpath "html/body/fieldset[8]/p/a[1]"
40
+
41
+ Scenario: Interacting with browser
42
+
43
+ Then I resize browser window size to width 400 and height 400
44
+ Then I maximize browser window
45
+ #Then I close browser
@@ -0,0 +1,7 @@
1
+ Feature: Assertion Steps
2
+ As a user I should able to verify using assert steps
3
+
4
+ Scenario: Open test page
5
+ Given I open test page
6
+
7
+
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,11 @@
1
+
2
+ Feature: Screenshot Step
3
+ As a user I should able to take screenshot
4
+
5
+ Scenario: Open test page
6
+
7
+ Given I open test page
8
+
9
+ Scenario: take screenshot
10
+
11
+ Then I take screenshot
@@ -0,0 +1,14 @@
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
+
@@ -0,0 +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
+
@@ -0,0 +1,34 @@
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