browser_shooter 0.2.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -38,53 +38,103 @@ Create a YAML file like this:
38
38
 
39
39
  # myconfig.yml
40
40
  output_path: "/tmp/shoots"
41
- logs_format: "csv"
42
-
43
- scripts:
44
- google:
45
- name: "google"
46
- # commands are WebDriver commands
47
- # except 'shot' command which receive an optional param with the 'sufix' of the page screenshot png
48
- # except 'pause' command which use a Ruby 'sleep' command to pause
49
- # except 'click' command whith receive a 'css_selector' as a param, find the element and click on it
50
- # except 'type' command whith receive two params: 'css_selector' ana a 'message', find the element and type the message on it
51
- # except 'wait_for_element' command whith receive two params: 'css_selector', and a 'timeout' in seconds
52
- commands: |
53
- navigate.to "http://www.google.de"
54
- shot before
55
- type "input[name='q']", "beautiful houses"
56
- click "input[name='btnG']"
57
- pause 3
58
- click "a.kls"
59
- pause 3
60
- shot after
41
+
42
+ tests:
43
+ google: |
44
+ navigate.to "http://www.google.de"
45
+ shot before
46
+ type "input[name='q']", "beautiful houses"
47
+ click "input[name='btnG']"
48
+ pause 3
49
+ click "a.kls"
50
+ pause 3
51
+ shot after
52
+
53
+ miniclip: |
54
+ navigate.to "http://www.miniclip.com/games/de/"
55
+ shot
61
56
 
62
57
  browsers:
63
58
  windows-firefox:
64
- name: "windows-firefox"
65
59
  url: "http://127.0.0.1:4444/wd/hub"
66
- browser: "firefox"
60
+ type: "firefox"
67
61
 
68
62
  windows-iexplore:
69
- name: "windows-iexploreproxy"
70
63
  url: "http://127.0.0.1:4444/wd/hub"
71
- browser: "*iexploreproxy"
64
+ type: "ie"
65
+
66
+ suites:
67
+ suite1:
68
+ tests:
69
+ - google
70
+ - miniclip
71
+ browsers:
72
+ - ios-firefox
73
+ - ios-chrome
74
+
75
+ suite2:
76
+ tests:
77
+ - google
78
+ browsers:
79
+ - ios-chrome
80
+
72
81
 
73
82
  Look in the [examples folder](https://github.com/fguillen/BrowserShooter/tree/master/examples) for more complete examples.
74
83
 
84
+ ##### Tests section
85
+
86
+ Commands are WebDriver commands, except:
87
+
88
+ * **shot** command which receive an optional param with the 'sufix' of the page screenshot png
89
+ * **pause** command which use a Ruby 'sleep' command to pause
90
+ * **click** command which receive a 'css_selector' as a param, find the element and click on it
91
+ * **type** command which receive two params: 'css_selector' ana a 'message', find the element and type the message on it
92
+ * **wait_for_element** command which receive two params: 'css_selector', and a 'timeout' in seconds
93
+
94
+ You can define as much tests as you want. Every test is composed by a list of **one line** commands.
95
+
96
+ ##### Browsers section
97
+
98
+ All the available browsers with the **selenium server url** and the **selenium browser type**.
99
+
100
+ ##### Suites section
101
+
102
+ Groups of **tests** and **browsers** to be executed as one.
103
+
75
104
 
76
105
  #### Run the BrowserShooter script
77
106
 
78
- $ browser_shooter ./my/config.yml
107
+ ##### The simple way
108
+
109
+ $ browser_shooter --config ./my/config.yml
110
+
111
+ ##### Choosing a suite
112
+
113
+ $ browser_shooter --config ./my/config.yml -s --suite suite1
114
+
115
+ ##### Choosing a test
116
+
117
+ $ browser_shooter --config ./my/config.yml -s --test google
118
+
119
+ ##### Choosing a test an a list of browsers
120
+
121
+ $ browser_shooter --config ./my/config.yml -s --test google --browsers windows-firefox,windows-iexplore
122
+
123
+ ##### Check all the options
124
+
125
+ $ browser_shooter --help
126
+
127
+
128
+ #### The output paths
79
129
 
80
130
  The screenshots will be stored in:
81
131
 
82
- /<output_path>/<time_stamp>/shots
132
+ /<output_path>/<time_stamp>/<suite_name>/<test_name>/<browser_name>/shots
83
133
 
84
134
  The logs will be stored in:
85
135
 
86
- /<output_path>/<time_stamp>/logs
136
+ /<output_path>/<time_stamp>/<suite_name>/<test_name>/<browser_name>/logs
87
137
 
88
138
  ## Status
89
139
 
90
- Still in a _discovery_ state.. but is already **functional**.
140
+ Still in a _development_ state.. but is already **functional**.
data/Rakefile CHANGED
@@ -12,6 +12,6 @@ task :default => :test
12
12
 
13
13
  Rake::TestTask.new do |t|
14
14
  t.libs << '.'
15
- t.test_files = FileList['test/*_test.rb']
15
+ t.test_files = FileList['test/**/*_test.rb']
16
16
  t.verbose = true
17
17
  end
data/bin/browser_shooter CHANGED
@@ -1,18 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Use:
4
- # browser_shooter /path/to/config.yml
5
-
6
3
  begin
7
4
  require 'browser_shooter'
5
+ # require_relative "../lib/browser_shooter"
8
6
  rescue LoadError
9
7
  require 'rubygems'
10
8
  require 'browser_shooter'
11
9
  end
12
10
 
13
- if ( ARGV.size != 1 )
14
- BrowserShooter::Logger.log "use: $ browser_shooter <config_file_path>"
15
- exit 1
16
- end
11
+ argv_parser = BrowserShooter::ARGVParsers.new
12
+ argv_parser.parse_options( ARGV )
17
13
 
18
- BrowserShooter.new( ARGV[0] ).run
14
+ BrowserShooter::Base.new( argv_parser.config ).run
@@ -18,8 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.add_development_dependency "mocha"
19
19
 
20
20
  s.add_dependency "selenium-webdriver"
21
- s.add_dependency "selenium"
22
- s.add_dependency "selenium-client"
21
+ s.add_dependency "mixlib-cli"
23
22
 
24
23
  s.files = `git ls-files`.split("\n")
25
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -0,0 +1,35 @@
1
+ output_path: "~/browser_shoots"
2
+
3
+ tests:
4
+ google: |
5
+ navigate.to "http://www.google.com"
6
+ shot
7
+
8
+ miniclip: |
9
+ navigate.to "http://www.miniclip.com/games/de/"
10
+ shot
11
+
12
+ browsers:
13
+ ios-firefox:
14
+ url: "http://127.0.0.1:4444/wd/hub"
15
+ type: "firefox"
16
+
17
+ ios-chrome:
18
+ url: "http://127.0.0.1:4444/wd/hub"
19
+ type: "chrome"
20
+
21
+ suites:
22
+ suite1:
23
+ tests:
24
+ - google
25
+ - miniclip
26
+ browsers:
27
+ - ios-firefox
28
+ - ios-chrome
29
+
30
+ suite2:
31
+ tests:
32
+ - google
33
+ browsers:
34
+ - ios-chrome
35
+
data/examples/config1.yml CHANGED
@@ -1,31 +1,34 @@
1
1
  output_path: "~/browser_shoots"
2
2
 
3
- scripts:
4
- google:
5
- name: "google"
6
- commands: |
7
- navigate.to "http://www.google.de"
8
- shot before
9
- type "input[name='q']", "beautiful houses"
10
- click "input[name='btnG']"
11
- pause 3
12
- click "a.kls"
13
- pause 3
14
- shot after
3
+ tests:
4
+ google: |
5
+ navigate.to "http://www.google.de"
6
+ shot before
7
+ type "input[name='q']", "beautiful houses"
8
+ click "input[name='btnG']"
9
+ pause 3
10
+ click "a.kls"
11
+ pause 3
12
+ shot after
15
13
 
16
- miniclip:
17
- name: "miniclip"
18
- commands: |
19
- navigate.to "http://www.miniclip.com/games/de/"
20
- shot
14
+ miniclip: |
15
+ navigate.to "http://www.miniclip.com/games/de/"
16
+ shot
21
17
 
22
18
  browsers:
23
19
  ios-firefox:
24
- name: "ios-firefox"
25
20
  url: "http://127.0.0.1:4444/wd/hub"
26
- browser: "firefox"
21
+ type: "firefox"
27
22
 
28
23
  ios-chrome:
29
- name: "ios-chrome"
30
24
  url: "http://127.0.0.1:4444/wd/hub"
31
- browser: "chrome"
25
+ type: "chrome"
26
+
27
+ suites:
28
+ suite1:
29
+ tests:
30
+ - google
31
+ - miniclip
32
+ browsers:
33
+ - ios-firefox
34
+ - ios-chrome
data/examples/config2.yml CHANGED
@@ -1,34 +1,54 @@
1
1
  output_path: "~/browser_shooter"
2
2
 
3
- scripts:
4
- lightbox:
5
- name: "lightbox"
6
- commands: |
7
- navigate.to "http://192.168.70.76:3000/test/browser_shooter/lightbox_bareplayer.html"
8
- shot 01_first
9
- pause 5
10
- switch_to.alert.accept
11
- click "a"
12
- pause 5
13
- shot 02_video
14
- switch_to.frame "_sp_wiframe"
15
- execute_script "$f().play()"
16
- pause 3
17
- shot 03_video_start
18
- wait_for_element "span.enabled", 40
19
- shot 04_green_button
20
- click "span.enabled"
21
- pause 8
22
- switch_to.alert.accept
23
- shot 05_spinner
24
- switch_to.default_content
25
- click "#sp_close_x"
26
- switch_to.alert.accept
27
- pause 4
28
- shot 06_hidden
3
+ tests:
4
+ lightbox: |
5
+ navigate.to "http://192.168.70.70/test/browser_shooter/lightbox_bareplayer.html"
6
+ shot 01_first
7
+ pause 5
8
+ switch_to.alert.accept
9
+ click "a"
10
+ pause 5
11
+ shot 02_video
12
+ switch_to.frame "_sp_wiframe"
13
+ execute_script "$f().play()"
14
+ pause 3
15
+ shot 03_video_start
16
+ wait_for_element "span.enabled", 40
17
+ shot 04_green_button
18
+ click "span.enabled"
19
+ pause 8
20
+ switch_to.alert.accept
21
+ shot 05_spinner
22
+ switch_to.default_content
23
+ click "#sp_close_x"
24
+ switch_to.alert.accept
25
+ pause 4
26
+ shot 06_hidden
29
27
 
30
28
  browsers:
31
29
  osx-chrome:
32
- name: "osx-chrome"
33
30
  url: "http://127.0.0.1:4444/wd/hub"
34
- browser: "chrome"
31
+ type: "chrome"
32
+
33
+ windows-chrome:
34
+ url: "http://10.211.55.4:4444/wd/hub"
35
+ type: "chrome"
36
+
37
+ windows-firefox:
38
+ url: "http://10.211.55.4:4444/wd/hub"
39
+ type: "firefox"
40
+
41
+ windows-ie:
42
+ url: "http://10.211.55.4:4444/wd/hub"
43
+ type: "ie"
44
+
45
+ suites:
46
+ suite1:
47
+ tests:
48
+ - lightbox
49
+ browsers:
50
+ - osx-crhome
51
+ - windows-chrome
52
+ - windows-firefox
53
+ - windows-ie
54
+
@@ -1,41 +1,17 @@
1
+ require "selenium-webdriver"
2
+ require "mixlib/cli"
3
+ require "yaml"
4
+ require "json"
5
+
6
+ require_relative "./browser_shooter/base"
7
+ require_relative "./browser_shooter/models/suite"
8
+ require_relative "./browser_shooter/models/test"
9
+ require_relative "./browser_shooter/models/browser"
1
10
  require_relative "./browser_shooter/version"
2
11
  require_relative "./browser_shooter/configurator"
3
12
  require_relative "./browser_shooter/logger"
4
- require_relative "./browser_shooter/driver"
5
13
  require_relative "./browser_shooter/commander"
6
14
  require_relative "./browser_shooter/log_exporter"
15
+ require_relative "./browser_shooter/argv_parser"
7
16
 
8
- require "selenium-webdriver"
9
- require "selenium-client"
10
- require "yaml"
11
- require "json"
12
-
13
- class BrowserShooter
14
- attr_reader :config_file_path
15
-
16
- def initialize( config_file_path )
17
- @config_file_path = config_file_path
18
- end
19
-
20
- def run
21
- BrowserShooter::Logger.log "Starting script running with version #{BrowserShooter::VERSION}..."
22
-
23
- config = BrowserShooter::Configurator.load_config( config_file_path )
24
- logs = {}
25
-
26
- config["scripts"].each_value do |script|
27
- config["browsers"].each_value do |browser|
28
- logs["#{script["name"]}_#{browser["name"]}"] =
29
- BrowserShooter::Driver.run_script_on_browser(script, browser, "#{config["output_path"]}/shots")
30
- end
31
- end
32
-
33
- BrowserShooter::LogExporter.export( logs, "#{config["output_path"]}/logs", config["logs_format"] )
34
-
35
- BrowserShooter::Logger.log "... script running ended."
36
- BrowserShooter::Logger.log "shots are in: #{config["output_path"]}/shots"
37
- BrowserShooter::Logger.log "logs are in: #{config["output_path"]}/logs"
38
- BrowserShooter::Logger.log "BYE!"
39
- end
40
- end
41
17
 
@@ -0,0 +1,54 @@
1
+ module BrowserShooter
2
+ class ARGVParsers
3
+ include Mixlib::CLI
4
+
5
+ option(
6
+ :config_file,
7
+ :short => "-c CONFIG",
8
+ :long => "--config CONFIG",
9
+ :required => true,
10
+ :description => "The configuration file to use"
11
+ )
12
+
13
+ option(
14
+ :suite,
15
+ :short => "-s SUITE",
16
+ :long => "--suite SUITE",
17
+ :description => "The name of the suite to execute",
18
+ )
19
+
20
+ option(
21
+ :test,
22
+ :short => "-t TEST",
23
+ :long => "--test TEST",
24
+ :description => "The name of the test to execute",
25
+ )
26
+
27
+ option(
28
+ :browsers,
29
+ :short => "-b BROWSERS",
30
+ :long => "--browsers BROWSERS",
31
+ :description => "The name of the browsers to execute, separated by comas",
32
+ :proc => Proc.new { |browsers| browsers.split(",") }
33
+ )
34
+
35
+ option(
36
+ :verbose,
37
+ :short => "-v",
38
+ :long => "--verbose",
39
+ :description => "More verbose output",
40
+ :boolean => true
41
+ )
42
+
43
+ option(
44
+ :help,
45
+ :short => "-h",
46
+ :long => "--help",
47
+ :description => "Show this message",
48
+ :on => :tail,
49
+ :boolean => true,
50
+ :show_options => true,
51
+ :exit => 0
52
+ )
53
+ end
54
+ end