selenium-cucumber 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/Example/expected_images/flower.png +0 -0
  3. data/Example/expected_images/flower1.png +0 -0
  4. data/Example/features/assertion_steps_Ex.feature +26 -18
  5. data/Example/image_difference/difference_20140814210820942.png +0 -0
  6. data/Example/image_difference/difference_20140815095331224.png +0 -0
  7. data/Example/image_difference/difference_20140815100021133.png +0 -0
  8. data/Example/image_difference/difference_20140815100348774.png +0 -0
  9. data/Example/image_difference/test.png +0 -0
  10. data/Example/run_features.rb +19 -17
  11. data/Example/screenshots/screenshot20140815095553337.png +0 -0
  12. data/Example/screenshots/screenshot20140815100120197.png +0 -0
  13. data/Example/screenshots/screenshot20140815100446914.png +0 -0
  14. data/Example/screenshots/test.png +0 -0
  15. data/bin/generate.rb +20 -20
  16. data/bin/helper.rb +50 -50
  17. data/bin/selenium-cucumber +29 -26
  18. data/doc/canned_steps.md +26 -3
  19. data/doc/installation.md +16 -16
  20. data/doc/selenium-cucumber-API.md +60 -21
  21. data/doc/selenium-cucumber-help.md +18 -18
  22. data/features-skeleton/expected_images/test.png +0 -0
  23. data/features-skeleton/image_difference/test.png +0 -0
  24. data/features-skeleton/my_first.feature +5 -5
  25. data/features-skeleton/screenshots/test.png +0 -0
  26. data/features-skeleton/step_definitions/custom_steps.rb +4 -4
  27. data/features-skeleton/support/env.rb +38 -38
  28. data/features-skeleton/support/hooks.rb +33 -33
  29. data/lib/selenium-cucumber.rb +2 -2
  30. data/lib/selenium-cucumber/methods/assertion_methods.rb +13 -9
  31. data/lib/selenium-cucumber/methods/navigate_methods.rb +3 -1
  32. data/lib/selenium-cucumber/methods/screenshot_methods.rb +1 -1
  33. data/lib/selenium-cucumber/version.rb +1 -1
  34. metadata +67 -13
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d305257fe405a3a6e3fdef64ba0238ac57f2fe3
4
+ data.tar.gz: 05c21ef7cb1e6a756f6cc21baee9a5f0442da258
5
+ SHA512:
6
+ metadata.gz: 96dcf390850fdbfcd240c64bf73e0a6af06289b63fb8d8764e12c6566080dfd4184e30484963accd8aaeb62ffdb4bf1cc569ed7b554fcd9d70ff91a91cdc5488
7
+ data.tar.gz: 8165bf844471dfa3cc4545f61a855aaa81c86e7d5b4c8fa8e7668bc3e5f2bcb26bbd005b4ef55d44430fb89bc8693c11a38895b626d516fe49266feed03f9728
Binary file
Binary file
@@ -1,21 +1,24 @@
1
1
 
2
2
  Feature: Assertion Steps
3
3
  As a user I should able to verify using assert steps
4
-
4
+
5
5
  Scenario: Open test page
6
6
  Given I open test page
7
-
7
+
8
8
  Scenario: verify page title
9
9
  Then I should see page title as "Test Page for selenium-cucumber"
10
-
10
+
11
11
 
12
12
  Scenario: verify element text
13
13
 
14
+ Then I scroll to end of page
14
15
  Then element having id "dbClick" should have text as "Double-click this paragraph to trigger a function."
15
16
  Then element having name "javascript_alert_msg" should have text as "Click the button to display a confirm box."
16
17
  Then element having class "form_name" should have text as "Simple sample form with input elements"
17
18
  Then element having xpath ".//*[@id='frm']/fieldset/p[1]/label" should have text as "Text input (first name)"
18
-
19
+
20
+ Scenario: verify element should not text
21
+
19
22
  Then element having id "dbClick" should not have text as "Double-click this"
20
23
  Then element having name "javascript_alert_msg" should not have text as "Click the button"
21
24
  Then element having class "form_name" should not have text as "Simple sample"
@@ -55,7 +58,7 @@ Feature: Assertion Steps
55
58
  Then element having name "he_name" should not be present
56
59
  Then element having class "he_class" should not be present
57
60
  Then element having xpath ".//*[@id='hiddenElement']" should not be present
58
-
61
+
59
62
  And I wait for 10 sec
60
63
 
61
64
  Then element having id "hiddenElement" should be present
@@ -69,17 +72,17 @@ Feature: Assertion Steps
69
72
  Then checkbox having name "chk5_name" should be checked
70
73
  Then checkbox having xpath ".//*[@id='chk1']" should be checked
71
74
  Then checkbox having class "chk5_class" should be checked
72
-
75
+
73
76
  Then checkbox having id "chk2" should be unchecked
74
77
  Then checkbox having name "chk3_name" should be unchecked
75
78
  Then checkbox having class "chk4_class" should be unchecked
76
79
 
77
80
  Scenario: verify checkbox checked or not - negative test 1
78
-
81
+
79
82
  Then checkbox having class "chk3_class" should be checked
80
83
 
81
84
  Scenario: verify checkbox checked or not - negative test 2
82
-
85
+
83
86
  Then checkbox having class "chk5_class" should be unchecked
84
87
 
85
88
  Scenario: verify radio button selected or not
@@ -101,21 +104,26 @@ Feature: Assertion Steps
101
104
  Then link having text "xyz" should not be present
102
105
 
103
106
  Scenario: verify pop-up alert text
104
-
107
+
105
108
  When I click on element having id "try_it"
106
109
  Then I should see alert text as "Press a button!"
107
- Then I accept alert
108
-
109
- Scenario: verify image by id
110
+ Then I accept alert
111
+
112
+ Scenario: verify image by id and id
110
113
  Then actual image having id "img1" and expected image having id "img1" should be similar
111
114
 
112
- Scenario: verify image by xpath
115
+ Scenario: verify image by xpath and xpath
113
116
  Then actual image having xpath ".//*[@id='img1']" and expected image having xpath ".//*[@id='img1']" should be similar
114
117
 
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
118
+ Scenario: verify image by id and image_name
119
+ Then actual image having id "img1" and expected image having image_name "flower.png" should be similar
120
+
121
+ Scenario: verify image by url and image_name
122
+ Then actual image having url "http://shared.ooyala.com.s3.amazonaws.com/dropshadow-flower-pink.png" and expected image having image_name "flower.png" should be similar
123
+
124
+ Scenario: verify image by id and image_name - negative test 1
125
+ Then actual image having id "img1" and expected image having image_name "flower1.png" should be similar
126
+
127
+
117
128
 
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
129
 
121
-
Binary file
@@ -1,9 +1,26 @@
1
- #!/usr/bin/env ruby
2
1
  require 'selenium-webdriver'
3
2
 
3
+ puts ARGV[0]
4
+
4
5
  OS=Selenium::WebDriver::Platform.os
5
6
 
6
- if ENV["OUTPUT"]=="html"
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
+ else
19
+ puts "Running all features on safari browser ###### \n\n"
20
+ system("cucumber BROWSER=safari")
21
+ end
22
+
23
+ elsif ARGV.shift == "html"
7
24
 
8
25
  puts "\n\n\t###### Running all features on firefox browser ###### \n\n"
9
26
  puts "Output result stored in \"result_firefox.html\""
@@ -22,19 +39,4 @@ if ENV["OUTPUT"]=="html"
22
39
  puts "Output result stored in \"result_safari.html\""
23
40
  system("cucumber BROWSER=safari -f html -o result_safari.html")
24
41
  end
25
- else
26
-
27
- puts "\n\n\t###### Running all features on firefox browser ######\n\n"
28
- system("cucumber")
29
-
30
- puts "\n\n\t###### Running all features on chrome browser ###### \n\n"
31
- system("cucumber BROWSER=chrome")
32
-
33
- if OS.to_s=="windows"
34
- puts "Running all features on internet explorer browser ###### \n\n"
35
- system("cucumber BROWSER=ie")
36
- else
37
- puts "Running all features on safari browser ###### \n\n"
38
- system("cucumber BROWSER=safari")
39
- end
40
42
  end
Binary file
data/bin/generate.rb CHANGED
@@ -1,20 +1,20 @@
1
-
2
- def selenium_cucumber_scaffold
3
- if File.exists?(@features_dir)
4
- puts "A features directory already exists. Stopping..."
5
- exit 1
6
- end
7
- msg("Question") do
8
- puts "I'm about to create a subdirectory called features."
9
- puts "features will contain all your project tests."
10
- puts "Please hit return to confirm that's what you want."
11
- end
12
- exit 2 unless STDIN.gets.chomp == ''
13
-
14
- FileUtils.cp_r(@source_dir, @features_dir)
15
-
16
- msg("Info") do
17
- puts "features subdirectory created. \n"
18
- end
19
-
20
- end
1
+
2
+ def selenium_cucumber_scaffold
3
+ if File.exists?(@features_dir)
4
+ puts "A features directory already exists. Stopping..."
5
+ exit 1
6
+ end
7
+ msg("Question") do
8
+ puts "I'm about to create a subdirectory called features."
9
+ puts "features will contain all your project tests."
10
+ puts "Please hit return to confirm that's what you want."
11
+ end
12
+ exit 2 unless STDIN.gets.chomp == ''
13
+
14
+ FileUtils.cp_r(@source_dir, @features_dir)
15
+
16
+ msg("Info") do
17
+ puts "features subdirectory created. \n"
18
+ end
19
+
20
+ end
data/bin/helper.rb CHANGED
@@ -1,51 +1,51 @@
1
- require 'tempfile'
2
- require 'json'
3
- require "rubygems"
4
-
5
- def msg(title, &block)
6
- puts "\n" + "-"*10 + title + "-"*10
7
- block.call
8
- puts "-"*10 + "-------" + "-"*10 + "\n"
9
- end
10
-
11
- def print_usage
12
- puts <<EOF
13
-
14
- Usage: selenium-cucumber <command-name> [parameters] [options]
15
-
16
- <command-name> can be one of
17
- help
18
- prints more detailed help information.
19
- gen
20
- generate a features folder structure.
21
- version
22
- prints the gem version
23
-
24
- <options> can be
25
- -v, --verbose Turns on verbose logging
26
- EOF
27
- end
28
-
29
- def print_help
30
- puts <<EOF
31
-
32
- Usage: selenium-cucumber <command-name> [parameters] [options]
33
-
34
- <command-name> can be one of
35
- help
36
- gen
37
- version
38
-
39
- Commands:
40
- help : prints more detailed help information.
41
-
42
- gen : creates a skeleton features dir. This is usually used once when
43
- setting up selnium-cucumber to ensure that the features folder contains
44
- the right step definitions and environment to run with cucumber.
45
-
46
- version : prints the gem version
47
-
48
- <Options>
49
- -v, --verbose Turns on verbose logging
50
- EOF
1
+ require 'tempfile'
2
+ require 'json'
3
+ require "rubygems"
4
+
5
+ def msg(title, &block)
6
+ puts "\n" + "-"*10 + title + "-"*10
7
+ block.call
8
+ puts "-"*10 + "-------" + "-"*10 + "\n"
9
+ end
10
+
11
+ def print_usage
12
+ puts <<EOF
13
+
14
+ Usage: selenium-cucumber <command-name> [parameters] [options]
15
+
16
+ <command-name> can be one of
17
+ help
18
+ prints more detailed help information.
19
+ gen
20
+ generate a features folder structure.
21
+ version
22
+ prints the gem version
23
+
24
+ <options> can be
25
+ -v, --verbose Turns on verbose logging
26
+ EOF
27
+ end
28
+
29
+ def print_help
30
+ puts <<EOF
31
+
32
+ Usage: selenium-cucumber <command-name> [parameters] [options]
33
+
34
+ <command-name> can be one of
35
+ help
36
+ gen
37
+ version
38
+
39
+ Commands:
40
+ help : prints more detailed help information.
41
+
42
+ gen : creates a skeleton features dir. This is usually used once when
43
+ setting up selnium-cucumber to ensure that the features folder contains
44
+ the right step definitions and environment to run with cucumber.
45
+
46
+ version : prints the gem version
47
+
48
+ <Options>
49
+ -v, --verbose Turns on verbose logging
50
+ EOF
51
51
  end
@@ -1,26 +1,29 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative 'helper.rb'
4
- require_relative 'generate.rb'
5
- require 'selenium-cucumber/version'
6
-
7
- @features_dir = File.join(FileUtils.pwd, "features")
8
- @support_dir = File.join(@features_dir, "support")
9
- @source_dir = File.join(File.dirname(__FILE__), '..', 'features-skeleton')
10
-
11
- if (ARGV.length == 0)
12
- print_usage
13
- else
14
- cmd = ARGV.shift
15
-
16
- if cmd == "help"
17
- print_help
18
- elsif cmd == "gen"
19
- selenium_cucumber_scaffold
20
- elsif cmd == "version"
21
- puts Selenium::Cucumber::VERSION
22
- else
23
- print_usage
24
- end
25
- end
26
-
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative 'helper.rb'
4
+ require_relative 'generate.rb'
5
+ require 'selenium-cucumber/version'
6
+
7
+ @features_dir = File.join(FileUtils.pwd, "features")
8
+ @support_dir = File.join(@features_dir, "support")
9
+ @support_dir = File.join(@features_dir, "expected_images")
10
+ @support_dir = File.join(@features_dir, "image_difference")
11
+ @support_dir = File.join(@features_dir, "screenshots")
12
+ @source_dir = File.join(File.dirname(__FILE__), '..', 'features-skeleton')
13
+
14
+ if (ARGV.length == 0)
15
+ print_usage
16
+ else
17
+ cmd = ARGV.shift
18
+
19
+ if cmd == "help"
20
+ print_help
21
+ elsif cmd == "gen"
22
+ selenium_cucumber_scaffold
23
+ elsif cmd == "version"
24
+ puts Selenium::Cucumber::VERSION
25
+ else
26
+ print_usage
27
+ end
28
+ end
29
+
data/doc/canned_steps.md CHANGED
@@ -256,9 +256,32 @@ To assert text on javascipt pop-up alert use following step :
256
256
 
257
257
  #### Steps For Asserting Difference in images
258
258
 
259
- To assert difference in actual image and expected image use following step :
260
-
261
- Then actual image "(.*?)" and expected image "(.*?)" should be similar
259
+ To assert difference in actual image and expected image (from remotely hosted) use following steps :
260
+
261
+ Then actual image having id "(.*?)" and expected image having url "(.*?)" should be similar
262
+ Then actual image having name "(.*?)" and expected image having url "(.*?)" should be similar
263
+ Then actual image having class "(.*?)" and expected image having url "(.*?)" should be similar
264
+ Then actual image having xpath "(.*?)" and expected image having url "(.*?)" should be similar
265
+ Then actual image having css "(.*?)" and expected image having url "(.*?)" should be similar
266
+ Then actual image having url "(.*?)" and expected image having url "(.*?)" should be similar
267
+
268
+ To assert difference in actual image and expected image (from local machine) use following steps :
269
+
270
+ Then actual image having id "(.*?)" and expected image having image_name "(.*?)" should be similar
271
+ Then actual image having name "(.*?)" and expected image having image_name "(.*?)" should be similar
272
+ Then actual image having class "(.*?)" and expected image having image_name "(.*?)" should be similar
273
+ Then actual image having xpath "(.*?)" and expected image having image_name "(.*?)" should be similar
274
+ Then actual image having css "(.*?)" and expected image having image_name "(.*?)" should be similar
275
+ Then actual image having url "(.*?)" and expected image having image_name "(.*?)" should be similar
276
+
277
+ To assert difference in actual image and expected image (from same webpage) use following steps :
278
+
279
+ Then actual image having id "(.*?)" and expected image having id "(.*?)" should be similar
280
+ Then actual image having name "(.*?)" and expected image having name "(.*?)" should be similar
281
+ Then actual image having class "(.*?)" and expected image having class "(.*?)" should be similar
282
+ Then actual image having xpath "(.*?)" and expected image having xpath "(.*?)" should be similar
283
+ Then actual image having css "(.*?)" and expected image having css "(.*?)" should be similar
284
+ Then actual image having url "(.*?)" and expected image having url "(.*?)" should be similar
262
285
 
263
286
 
264
287
  Input Steps
data/doc/installation.md CHANGED
@@ -1,16 +1,16 @@
1
- Installation
2
- ============
3
- ### Prerequisites
4
- You need to have Ruby installed.
5
- Verify your installation by running ruby -v in a terminal - it should print "ruby 1.9.3" (or higher).
6
-
7
- You need to have DevKit installed.
8
-
9
- You can get Ruby and DevKit from [RubyInstaller.org](http://rubyinstaller.org/)
10
-
11
- ### Installation
12
-
13
- Install `selenium-cucumber` gem by running
14
-
15
- - `gem install selenium-cucumber`
16
-
1
+ Installation
2
+ ============
3
+ ### Prerequisites
4
+ You need to have Ruby installed.
5
+ Verify your installation by running ruby -v in a terminal - it should print "ruby 1.9.3" (or higher).
6
+
7
+ You need to have DevKit installed.
8
+
9
+ You can get Ruby and DevKit from [RubyInstaller.org](http://rubyinstaller.org/)
10
+
11
+ ### Installation
12
+
13
+ Install `selenium-cucumber` gem by running
14
+
15
+ - `gem install selenium-cucumber`
16
+
@@ -1,5 +1,5 @@
1
- selenium-cucumber API
2
- =====================
1
+ Selenium-Cucumber Ruby API's
2
+ ============================
3
3
 
4
4
  If you are writing code for your custom steps you can use the following methods :
5
5
 
@@ -8,9 +8,9 @@ Note : For some of the API paramtere values are fixed. Such values for paramater
8
8
  Navigation API's
9
9
  ----------------
10
10
 
11
- navigate_to(link)
11
+ navigate_to("link")
12
12
 
13
- navigate(direction) # direction => "back"/"forward"
13
+ navigate(direction) # direction => "back" / "forward"
14
14
 
15
15
  close_driver()
16
16
 
@@ -18,27 +18,31 @@ Navigation API's
18
18
  Browser Interaction API's
19
19
  -------------------------
20
20
 
21
- resize_browser(width,height)
21
+ resize_browser(width, height)
22
22
 
23
- scroll_page(to) # to => "top"/"end"
23
+ scroll_page(to) # to => "top" / "end"
24
24
 
25
- scroll_to_element(by,access_value)
25
+ scroll_to_element(by, access_value)
26
26
 
27
- zoom_in_out(in_out) # in_out => "add"/"subtract"
27
+ zoom_in_out(in_out) # in_out => "add" / "subtract"
28
28
 
29
- zoom_in_out_till_element_display(by, in_out, access_value) # in_out => "add"/"subtract"
29
+ zoom_in_out_till_element_display(by, in_out, access_value) # in_out => "add" / "subtract"
30
30
 
31
31
 
32
32
  Input API's
33
33
  ------------
34
34
 
35
- click(by,access_value)
35
+ click(by, access_value)
36
36
 
37
- submit(by,access_value)
37
+ double_click(access_type,access_value)
38
38
 
39
- enter_text(by,text,access_value)
39
+ click_forcefully(access_type, access_name)
40
40
 
41
- clear_text(by,access_value)
41
+ submit(by, access_value)
42
+
43
+ enter_text(by, text, access_value)
44
+
45
+ clear_text(by, access_value)
42
46
 
43
47
  check_checkbox(by, access_value)
44
48
 
@@ -50,19 +54,25 @@ Input API's
50
54
 
51
55
  get_page_title()
52
56
 
53
- get_element_text(by,access_value)
57
+ get_element_text(by, access_value)
54
58
 
55
- get_element_attribute(by,access_value,attribute)
59
+ get_element_attribute(by, access_value, attribute)
56
60
 
57
- is_element_enabled(by,access_value)
61
+ is_element_enabled(by, access_value)
58
62
 
59
- is_element_displayed(by,access_value)
63
+ is_element_displayed(by, access_value)
60
64
 
65
+ hover_over_element(by, access_value)
61
66
 
67
+ by => "locators type" ("id", "name", "class", "xpath", "css")
68
+
69
+ access_value => "locator value"
70
+
71
+
62
72
  Javascript Handling API
63
73
  -----------------------
64
74
 
65
- handle_alert(decision) # decision => "accept"/"dismiss"
75
+ handle_alert(decision) # decision => "accept" / "dismiss"
66
76
 
67
77
  get_alert_text
68
78
 
@@ -72,11 +82,40 @@ Progress API's
72
82
 
73
83
  wait(time_in_sec)
74
84
 
75
- wait_for_element_to_display(by,access_value,duration)
85
+ wait_for_element_to_display(by, access_value, duration)
86
+
87
+ wait_for_element_to_enable(by, access_value, duration)
88
+
89
+
90
+ by => "locators type" ("id", "name", "class", "xpath", "css")
91
+
92
+ access_value => "locator value"
93
+
94
+ duration => duration in seconds.
95
+
76
96
 
77
- wait_for_element_to_enable(by,access_value,duration)
97
+ Image Comparing API
98
+ -------------------
99
+
100
+ does_images_similar?(actual_img_by, actual_img_access_value, excp_img_by, excp_img_access_value)
101
+
102
+
103
+ actual_img_by => "element locators" ("id", "name", "class", "xpath", "css", "url")
104
+
105
+ actual_img_access_value => "locator value"
106
+
107
+
108
+ excp_img_by => "image location" ("id", "url", "image_name")
109
+
110
+ excp_img_access_value => "value"
78
111
 
79
112
 
80
113
  Screenshot API
81
114
  --------------
82
- take_screenshots
115
+ take_screenshots
116
+
117
+
118
+ Configuration API
119
+ -----------------
120
+
121
+ print_congifugartion
@@ -1,18 +1,18 @@
1
-
2
- Usage: selenium-cucumber <command-name> [parameters] [options]
3
-
4
- <command-name> can be one of
5
- help
6
- gen
7
- version
8
-
9
- Commands:
10
- help : prints more detailed help information.
11
-
12
- gen : creates a skeleton features dir. This is usually used once when
13
- setting up selnium-cucumber to ensure that the features folder contains
14
- the right step definitions and environment to run with cucumber.
15
-
16
- version : prints the gem version
17
-
18
- Options: -v, --verbose Turns on verbose logging
1
+
2
+ Usage: selenium-cucumber <command-name> [parameters] [options]
3
+
4
+ <command-name> can be one of
5
+ help
6
+ gen
7
+ version
8
+
9
+ Commands:
10
+ help : prints more detailed help information.
11
+
12
+ gen : creates a skeleton features dir. This is usually used once when
13
+ setting up selnium-cucumber to ensure that the features folder contains
14
+ the right step definitions and environment to run with cucumber.
15
+
16
+ version : prints the gem version
17
+
18
+ Options: -v, --verbose Turns on verbose logging
@@ -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,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.
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
34
  end
@@ -1,2 +1,2 @@
1
-
2
- Dir[File.dirname(__FILE__) + '/selenium-cucumber/*.rb'].each {|file| require file }
1
+
2
+ Dir[File.dirname(__FILE__) + '/selenium-cucumber/*.rb'].each {|file| require file }
@@ -168,25 +168,29 @@ end
168
168
  #Method to find difference between images
169
169
  def does_images_similar?(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name)
170
170
  if !compare_image(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name)
171
- raise TestCaseFailed , "Actual image is different from expected image"
171
+ raise TestCaseFailed , "Actual image is different from expected image"
172
172
  end
173
173
  end
174
174
 
175
175
  #Method to compare two images
176
176
  def compare_image(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name)
177
177
 
178
- if actual_img_access_type!="path"
179
- actual_img_url = get_element_attribute(actual_img_access_type, actual_img_access_name, "src")
180
- else
178
+ if actual_img_access_type == "url"
181
179
  actual_img_url = actual_img_access_name
180
+ else
181
+ actual_img_url = get_element_attribute(actual_img_access_type, actual_img_access_name, "src")
182
182
  end
183
183
 
184
- if excp_img_access_type!="path"
185
- expected_img_url = get_element_attribute(excp_img_access_type, excp_img_access_name, "src")
186
- else
184
+ if excp_img_access_type == "url"
187
185
  expected_img_url = excp_img_access_name
186
+ elsif excp_img_access_type == "image_name"
187
+ expected_img_url = File.absolute_path("expected_images/"+excp_img_access_name)
188
+ else
189
+ expected_img_url = get_element_attribute(excp_img_access_type, excp_img_access_name, "src")
188
190
  end
189
191
 
192
+ puts "\nActual image url : #{actual_img_url}"
193
+
190
194
  images = [
191
195
  ChunkyPNG::Image.from_file(open(actual_img_url)),
192
196
  ChunkyPNG::Image.from_file(open(expected_img_url))
@@ -208,8 +212,8 @@ def compare_image(actual_img_access_type, actual_img_access_name, excp_img_acces
208
212
  x, y = diff.map{ |xy| xy[0] }, diff.map{ |xy| xy[1] }
209
213
  images.last.rect(x.min, y.min, x.max, y.max, ChunkyPNG::Color.rgb(0,255,0))
210
214
  curTime = Time.now.strftime('%Y%m%d%H%M%S%L')
211
- images.last.save("difference_#{curTime}.png")
212
-
215
+ images.last.save("image_difference/difference_#{curTime}.png")
216
+
213
217
  puts "\nDifference between images saved as : difference_#{curTime}.png\n"
214
218
  return false
215
219
  else
@@ -24,8 +24,10 @@ def get_key
24
24
  os=Selenium::WebDriver::Platform.os
25
25
  if os.to_s=="windows"
26
26
  return "control"
27
- elsif os.to_s=="mac"
27
+ elsif os.to_s=="macosx"
28
28
  return "command"
29
+ else
30
+ raise "Invalid OS"
29
31
  end
30
32
  end
31
33
 
@@ -2,5 +2,5 @@ require_relative 'required_files'
2
2
 
3
3
  def take_screenshot
4
4
  curTime = Time.now.strftime('%Y%m%d%H%M%S%L')
5
- $driver.save_screenshot('./screenshot'+curTime+'.png')
5
+ $driver.save_screenshot('screenshots/screenshot'+curTime+'.png')
6
6
  end
@@ -1,5 +1,5 @@
1
1
  module Selenium
2
2
  module Cucumber
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,19 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sameer Sawant
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-10 00:00:00.000000000 Z
13
- dependencies: []
14
- description: ! "Selenium-cucumber is a behavior driven development (BDD) approach
15
- to write automation test script to test web applications.\n It
16
- enables you to write and execute automated acceptance tests of web apps."
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cucumber
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: selenium-webdriver
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: chunky_png
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: |-
56
+ Selenium-cucumber is a behavior driven development (BDD) approach to write automation test script to test web applications.
57
+ It enables you to write and execute automated acceptance tests of web apps.
17
58
  email: sameersawant1992@gmail.com
18
59
  executables:
19
60
  - selenium-cucumber
@@ -47,10 +88,15 @@ files:
47
88
  - doc/installation.md
48
89
  - doc/selenium-cucumber-API.md
49
90
  - doc/selenium-cucumber-help.md
91
+ - features-skeleton/expected_images/test.png
92
+ - features-skeleton/image_difference/test.png
50
93
  - features-skeleton/my_first.feature
94
+ - features-skeleton/screenshots/test.png
51
95
  - features-skeleton/step_definitions/custom_steps.rb
52
96
  - features-skeleton/support/env.rb
53
97
  - features-skeleton/support/hooks.rb
98
+ - Example/expected_images/flower.png
99
+ - Example/expected_images/flower1.png
54
100
  - Example/features/assertion_steps_Ex.feature
55
101
  - Example/features/click_steps_Ex.feature
56
102
  - Example/features/configuration_step_Ex.feature
@@ -63,31 +109,39 @@ files:
63
109
  - Example/features/step_definitions/custom_steps.rb
64
110
  - Example/features/support/env.rb
65
111
  - Example/features/support/hooks.rb
112
+ - Example/image_difference/difference_20140814210820942.png
113
+ - Example/image_difference/difference_20140815095331224.png
114
+ - Example/image_difference/difference_20140815100021133.png
115
+ - Example/image_difference/difference_20140815100348774.png
116
+ - Example/image_difference/test.png
66
117
  - Example/run_features.rb
118
+ - Example/screenshots/screenshot20140815095553337.png
119
+ - Example/screenshots/screenshot20140815100120197.png
120
+ - Example/screenshots/screenshot20140815100446914.png
121
+ - Example/screenshots/test.png
67
122
  - Example/test_page.html
68
123
  homepage: http://seleniumcucumber.wordpress.com/
69
124
  licenses:
70
125
  - MIT
126
+ metadata: {}
71
127
  post_install_message: Thanks for installing selenium-cucumber gem.
72
128
  rdoc_options: []
73
129
  require_paths:
74
130
  - lib
75
131
  required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
132
  requirements:
78
- - - ! '>='
133
+ - - '>='
79
134
  - !ruby/object:Gem::Version
80
135
  version: '0'
81
136
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
137
  requirements:
84
- - - ! '>='
138
+ - - '>='
85
139
  - !ruby/object:Gem::Version
86
140
  version: '0'
87
141
  requirements: []
88
142
  rubyforge_project:
89
- rubygems_version: 1.8.28
143
+ rubygems_version: 2.0.14
90
144
  signing_key:
91
- specification_version: 3
145
+ specification_version: 4
92
146
  summary: SELENIUM WEBDRIVER WITH RUBY & CUCUMBER
93
147
  test_files: []