browser_shooter 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +4 -0
- data/README.md +3 -5
- data/bin/browser_shooter +0 -0
- data/browser_shoter.gemspec +2 -0
- data/examples/config1.yml +1 -1
- data/examples/config2.yml +1 -1
- data/examples/config3.yml +1 -1
- data/examples/config4.yml +26 -0
- data/examples/config5.yml +18 -0
- data/lib/browser_shooter/commander.rb +42 -6
- data/lib/browser_shooter/configurator.rb +31 -0
- data/lib/browser_shooter/driver.rb +12 -13
- data/lib/browser_shooter/log_exporter.rb +28 -0
- data/lib/browser_shooter/version.rb +1 -1
- data/lib/browser_shooter.rb +15 -20
- data/test/browser_shooter_test.rb +17 -1
- data/test/commander_test.rb +89 -0
- data/test/configurator_test.rb +16 -0
- data/test/driver_test.rb +39 -0
- data/test/fixtures/config.yml +3 -17
- data/test/fixtures/config_simple.yml +11 -0
- data/test/fixtures/screenshot.base64 +0 -0
- data/test/test_helper.rb +27 -1
- metadata +87 -94
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -32,7 +32,7 @@ Repeat this steps in every VM.
|
|
32
32
|
Create a YAML file like this:
|
33
33
|
|
34
34
|
# myconfig.yml
|
35
|
-
|
35
|
+
output_path: "/tmp/shoots"
|
36
36
|
|
37
37
|
scripts:
|
38
38
|
google:
|
@@ -73,10 +73,8 @@ Look in the `examples` folder for more complete examples.
|
|
73
73
|
|
74
74
|
The screenshots will be stored in:
|
75
75
|
|
76
|
-
/<
|
76
|
+
/<output_path>/<time_stamp>/<script_name>_<browser_name>[_<sufix>].png
|
77
77
|
|
78
78
|
## Status
|
79
79
|
|
80
|
-
Still in a _discovery_ state..
|
81
|
-
|
82
|
-
But is functional a can be usefull in no-production environments.
|
80
|
+
Still in a _discovery_ state.. but is already **functional**.
|
data/bin/browser_shooter
CHANGED
File without changes
|
data/browser_shoter.gemspec
CHANGED
@@ -15,6 +15,8 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
|
17
17
|
s.add_development_dependency "rake", "0.9.2.2"
|
18
|
+
s.add_development_dependency "mocha"
|
19
|
+
|
18
20
|
s.add_dependency "selenium-webdriver"
|
19
21
|
s.add_dependency "selenium"
|
20
22
|
s.add_dependency "selenium-client"
|
data/examples/config1.yml
CHANGED
data/examples/config2.yml
CHANGED
data/examples/config3.yml
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
output_path: "~/browser_shooter"
|
2
|
+
|
3
|
+
scripts:
|
4
|
+
lightbox:
|
5
|
+
name: "lightbox"
|
6
|
+
url: "http://localhost:3000"
|
7
|
+
commands: |
|
8
|
+
open "/test/browser_shooter/lightbox_bareplayer.html"
|
9
|
+
window_maximize
|
10
|
+
pause 5
|
11
|
+
alert
|
12
|
+
click "link=Show video"
|
13
|
+
pause 5
|
14
|
+
select_frame "_sp_wiframe"
|
15
|
+
run_script "$f().play()"
|
16
|
+
wait_for_element "css=span.enabled", :timeout_in_seconds => 15
|
17
|
+
click "css=span.enabled"
|
18
|
+
pause 5
|
19
|
+
alert
|
20
|
+
|
21
|
+
browsers:
|
22
|
+
windows-firefox:
|
23
|
+
name: "osx-firefox"
|
24
|
+
host: 127.0.0.1
|
25
|
+
port: 4444
|
26
|
+
browser: "*firefox"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
output_path: "~/browser_shooter"
|
2
|
+
|
3
|
+
scripts:
|
4
|
+
lightbox:
|
5
|
+
name: "lightbox"
|
6
|
+
url: "http://localhost:3000"
|
7
|
+
commands: |
|
8
|
+
open "/test/browser_shooter/lightbox_bareplayer.html"
|
9
|
+
window_maximize
|
10
|
+
shot
|
11
|
+
|
12
|
+
|
13
|
+
browsers:
|
14
|
+
windows-firefox:
|
15
|
+
name: "osx-firefox"
|
16
|
+
host: 127.0.0.1
|
17
|
+
port: 4444
|
18
|
+
browser: "*firefox"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class BrowserShooter
|
2
2
|
module Commander
|
3
|
-
def self.execute( command, client,
|
3
|
+
def self.execute( command, client, output_path )
|
4
4
|
BrowserShooter::Logger.log "command: #{command}"
|
5
5
|
|
6
6
|
if( command.split[0].strip == "shot" )
|
@@ -8,7 +8,7 @@ class BrowserShooter
|
|
8
8
|
|
9
9
|
BrowserShooter::Commander.shot(
|
10
10
|
client,
|
11
|
-
|
11
|
+
output_path,
|
12
12
|
sufix
|
13
13
|
)
|
14
14
|
|
@@ -17,7 +17,7 @@ class BrowserShooter
|
|
17
17
|
|
18
18
|
BrowserShooter::Commander.shot_system(
|
19
19
|
client,
|
20
|
-
|
20
|
+
output_path,
|
21
21
|
sufix
|
22
22
|
)
|
23
23
|
|
@@ -30,6 +30,36 @@ class BrowserShooter
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.wrapper_execute( command, client, output_path )
|
34
|
+
result = {
|
35
|
+
:time => Time.now.to_i,
|
36
|
+
:command => command
|
37
|
+
}
|
38
|
+
|
39
|
+
begin
|
40
|
+
message =
|
41
|
+
BrowserShooter::Commander.execute(
|
42
|
+
command,
|
43
|
+
client,
|
44
|
+
output_path
|
45
|
+
)
|
46
|
+
|
47
|
+
result.merge!(
|
48
|
+
:success => true,
|
49
|
+
:message => message
|
50
|
+
)
|
51
|
+
|
52
|
+
rescue Exception => e
|
53
|
+
result.merge!(
|
54
|
+
:success => false,
|
55
|
+
:message => e.message
|
56
|
+
)
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
return result
|
61
|
+
end
|
62
|
+
|
33
63
|
def self.shot( client, path, sufix = nil )
|
34
64
|
sufix = "_#{sufix}" unless sufix.nil?
|
35
65
|
path = "#{path}#{sufix}.png"
|
@@ -39,22 +69,28 @@ class BrowserShooter
|
|
39
69
|
File.open( path, "wb" ) do |f|
|
40
70
|
f.write( Base64.decode64( client.capture_entire_page_screenshot_to_string( "" ) ) )
|
41
71
|
end
|
72
|
+
|
73
|
+
return path
|
42
74
|
end
|
43
75
|
|
44
76
|
def self.shot_system( client, path, sufix = nil )
|
45
77
|
sufix = "_#{sufix}" unless sufix.nil?
|
46
|
-
path = "#{path}#{sufix}
|
78
|
+
path = "#{path}#{sufix}.system.png"
|
47
79
|
|
48
80
|
BrowserShooter::Logger.log "shooting system in '#{path}'"
|
49
81
|
|
50
|
-
File.open(
|
82
|
+
File.open( path, "wb" ) do |f|
|
51
83
|
f.write( Base64.decode64( client.capture_screenshot_to_string ) )
|
52
84
|
end
|
85
|
+
|
86
|
+
return path
|
53
87
|
end
|
54
88
|
|
55
89
|
def self.pause( seconds )
|
56
90
|
BrowserShooter::Logger.log "pausing #{seconds} seconds"
|
57
|
-
sleep seconds
|
91
|
+
Kernel.sleep seconds
|
92
|
+
|
93
|
+
return "#{seconds} later..."
|
58
94
|
end
|
59
95
|
end
|
60
96
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class BrowserShooter
|
2
|
+
module Configurator
|
3
|
+
def self.load_config( config_file_path )
|
4
|
+
config = {
|
5
|
+
"output_path" => "~/browser_shooter",
|
6
|
+
"logs_format" => "csv"
|
7
|
+
}
|
8
|
+
|
9
|
+
config.merge! YAML.load_file( config_file_path )
|
10
|
+
|
11
|
+
config["output_path"] = set_up_output_path( config["output_path"] )
|
12
|
+
|
13
|
+
config
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.set_up_output_path( output_path )
|
17
|
+
output_path = File.expand_path( "#{output_path}/#{timestamp}" )
|
18
|
+
BrowserShooter::Logger.log( "output_path: #{output_path}" )
|
19
|
+
|
20
|
+
FileUtils.mkdir_p( output_path )
|
21
|
+
FileUtils.mkdir( "#{output_path}/shots" )
|
22
|
+
FileUtils.mkdir( "#{output_path}/logs" )
|
23
|
+
|
24
|
+
output_path
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.timestamp
|
28
|
+
Time.now.strftime("%Y%m%d%H%M%S")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class BrowserShooter
|
2
2
|
module Driver
|
3
|
-
def self.run_script_on_browser(script, browser,
|
4
|
-
BrowserShooter::Logger.log "Runing script '#{script["name"]}' with url '#{script["url"]}' in browser '#{browser["name"]}'"
|
5
|
-
|
3
|
+
def self.run_script_on_browser(script, browser, output_path)
|
6
4
|
client = nil
|
7
5
|
|
8
6
|
begin
|
7
|
+
BrowserShooter::Logger.log "Runing script '#{script["name"]}' with url '#{script["url"]}' in browser '#{browser["name"]}'"
|
8
|
+
|
9
9
|
client =
|
10
10
|
Selenium::Client::Driver.new(
|
11
11
|
:host => browser["host"],
|
@@ -17,17 +17,16 @@ class BrowserShooter
|
|
17
17
|
|
18
18
|
client.start_new_browser_session
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
logs =
|
21
|
+
script["commands"].lines.map do |command|
|
22
|
+
BrowserShooter::Commander.wrapper_execute(
|
23
|
+
command.strip,
|
24
|
+
client,
|
25
|
+
"#{output_path}/#{script["name"]}_#{browser["name"]}"
|
26
|
+
)
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
BrowserShooter::Logger.log "ERROR: #{e.message}"
|
30
|
-
# puts e.backtrace
|
29
|
+
logs
|
31
30
|
|
32
31
|
ensure
|
33
32
|
client.close_current_browser_session if client
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class BrowserShooter
|
2
|
+
module LogExporter
|
3
|
+
def self.export( path, logs, format )
|
4
|
+
BrowserShooter::Logger.log "Exporting '#{format}' logs to #{path}"
|
5
|
+
send(:"export_to_#{format}", path, logs )
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.export_to_json( path, logs )
|
9
|
+
File.open( "#{path}.json", "w" ) do |f|
|
10
|
+
f.write JSON.pretty_generate( logs )
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.export_to_csv( path, logs )
|
15
|
+
logs.each do |script_name, results|
|
16
|
+
_path = File.expand_path "#{path}/#{script_name}.csv"
|
17
|
+
|
18
|
+
File.open( _path, "w" ) do |f|
|
19
|
+
f.puts results.first.keys.join( " | " )
|
20
|
+
|
21
|
+
results.each do |result|
|
22
|
+
f.puts result.values.join( " | " )
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/browser_shooter.rb
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
require_relative "./browser_shooter/version"
|
2
|
+
require_relative "./browser_shooter/configurator"
|
2
3
|
require_relative "./browser_shooter/logger"
|
3
4
|
require_relative "./browser_shooter/driver"
|
4
5
|
require_relative "./browser_shooter/commander"
|
6
|
+
require_relative "./browser_shooter/log_exporter"
|
5
7
|
|
6
8
|
require "selenium-webdriver"
|
7
9
|
require "selenium-client"
|
8
10
|
require "yaml"
|
11
|
+
require "json"
|
9
12
|
|
10
13
|
class BrowserShooter
|
11
|
-
attr_reader :
|
14
|
+
attr_reader :config_file_path
|
12
15
|
|
13
16
|
def initialize( config_file_path )
|
14
|
-
@
|
15
|
-
end
|
16
|
-
|
17
|
-
def load_config( config_file_path )
|
18
|
-
config = YAML.load_file( config_file_path )
|
19
|
-
config = set_up_shoots_path( config )
|
20
|
-
|
21
|
-
config
|
17
|
+
@config_file_path = config_file_path
|
22
18
|
end
|
23
19
|
|
24
20
|
def run
|
25
21
|
BrowserShooter::Logger.log "Starting script running with version #{BrowserShooter::VERSION}..."
|
26
22
|
|
23
|
+
config = BrowserShooter::Configurator.load_config( config_file_path )
|
24
|
+
logs = {}
|
25
|
+
|
27
26
|
config["scripts"].each_value do |script|
|
28
27
|
config["browsers"].each_value do |browser|
|
29
|
-
|
28
|
+
logs["#{script["name"]}_#{browser["name"]}"] =
|
29
|
+
BrowserShooter::Driver.run_script_on_browser(script, browser, config["output_path"])
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
BrowserShooter::
|
34
|
-
end
|
35
|
-
|
36
|
-
def set_up_shoots_path( config )
|
37
|
-
config["shoots_path"] = File.expand_path( "#{config["shoots_path"]}/#{Time.now.strftime("%Y%m%d%H%M%S")}" )
|
38
|
-
BrowserShooter::Logger.log( "shoots_path: #{config["shoots_path"]}" )
|
39
|
-
|
40
|
-
FileUtils.mkdir_p( config["shoots_path"] )
|
33
|
+
BrowserShooter::LogExporter.export( "#{config["output_path"]}/logs", logs, config["logs_format"] )
|
41
34
|
|
42
|
-
|
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!"
|
43
39
|
end
|
44
|
-
|
45
40
|
end
|
46
41
|
|
@@ -1,7 +1,23 @@
|
|
1
1
|
require_relative "test_helper"
|
2
2
|
|
3
3
|
class BrowserScreenshotTest < Test::Unit::TestCase
|
4
|
+
def test_initialize
|
5
|
+
assert_equal( "filepath", BrowserShooter.new( "filepath" ).config_file_path )
|
6
|
+
end
|
7
|
+
|
4
8
|
def test_run
|
5
|
-
|
9
|
+
config_file_path = "#{FIXTURES}/config_simple.yml"
|
10
|
+
BrowserShooter::Configurator.expects( :load_config ).with( config_file_path ).returns( YAML.load_file( config_file_path ) )
|
11
|
+
|
12
|
+
BrowserShooter::Driver.expects( :run_script_on_browser).with( "script-one", "browser-one", "/shoots-path" )
|
13
|
+
BrowserShooter::Driver.expects( :run_script_on_browser).with( "script-one", "browser-two", "/shoots-path" )
|
14
|
+
BrowserShooter::Driver.expects( :run_script_on_browser).with( "script-one", "browser-three", "/shoots-path" )
|
15
|
+
BrowserShooter::Driver.expects( :run_script_on_browser).with( "script-two", "browser-one", "/shoots-path" )
|
16
|
+
BrowserShooter::Driver.expects( :run_script_on_browser).with( "script-two", "browser-two", "/shoots-path" )
|
17
|
+
BrowserShooter::Driver.expects( :run_script_on_browser).with( "script-two", "browser-three", "/shoots-path" )
|
18
|
+
|
19
|
+
BrowserShooter::Util.expects( :export_logs_to_csv )
|
20
|
+
|
21
|
+
BrowserShooter.new( config_file_path ).run
|
6
22
|
end
|
7
23
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
class CommanderTest < Test::Unit::TestCase
|
4
|
+
def test_execute_when_shot_with_sufix
|
5
|
+
BrowserShooter::Commander.expects( :shot ).with( "client", "shoot-path", "sufix" )
|
6
|
+
BrowserShooter::Commander.execute( "shot sufix", "client", "shoot-path" )
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_execute_when_shot_without_sufix
|
10
|
+
BrowserShooter::Commander.expects( :shot ).with( "client", "shoot-path", nil )
|
11
|
+
BrowserShooter::Commander.execute( "shot", "client", "shoot-path" )
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_execute_when_shot_system_with_sufix
|
15
|
+
BrowserShooter::Commander.expects( :shot_system ).with( "client", "shoot-path", "sufix" )
|
16
|
+
BrowserShooter::Commander.execute( "shot_system sufix", "client", "shoot-path" )
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_execute_when_shot_system_without_sufix
|
20
|
+
BrowserShooter::Commander.expects( :shot_system ).with( "client", "shoot-path", nil )
|
21
|
+
BrowserShooter::Commander.execute( "shot_system", "client", "shoot-path" )
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_execute_when_shot_pause
|
25
|
+
BrowserShooter::Commander.expects( :pause ).with( 10 )
|
26
|
+
BrowserShooter::Commander.execute( "pause 10", "client", "shoot-path" )
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_shot_with_sufix
|
30
|
+
in_tmpdir do |tmpdir|
|
31
|
+
client = stub( :capture_entire_page_screenshot_to_string => read_fixture( "screenshot.base64" ) )
|
32
|
+
path = "#{tmpdir}/myfile"
|
33
|
+
|
34
|
+
BrowserShooter::Commander.shot( client, path, "sufix" )
|
35
|
+
|
36
|
+
assert_equal(
|
37
|
+
Digest::MD5.hexdigest( Base64.decode64( read_fixture( "screenshot.base64" ) ) ),
|
38
|
+
Digest::MD5.hexdigest( File.read( "#{path}_sufix.png" ) )
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_shot_without_sufix
|
44
|
+
in_tmpdir do |tmpdir|
|
45
|
+
client = stub( :capture_entire_page_screenshot_to_string => read_fixture( "screenshot.base64" ) )
|
46
|
+
path = "#{tmpdir}/myfile"
|
47
|
+
|
48
|
+
BrowserShooter::Commander.shot( client, path, nil )
|
49
|
+
|
50
|
+
assert_equal(
|
51
|
+
Digest::MD5.hexdigest( Base64.decode64( read_fixture( "screenshot.base64" ) ) ),
|
52
|
+
Digest::MD5.hexdigest( File.read( "#{path}.png" ) )
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_shot_system_with_sufix
|
58
|
+
in_tmpdir do |tmpdir|
|
59
|
+
client = stub( :capture_screenshot_to_string => read_fixture( "screenshot.base64" ) )
|
60
|
+
path = "#{tmpdir}/myfile"
|
61
|
+
|
62
|
+
BrowserShooter::Commander.shot_system( client, path, "sufix" )
|
63
|
+
|
64
|
+
assert_equal(
|
65
|
+
Digest::MD5.hexdigest( Base64.decode64( read_fixture( "screenshot.base64" ) ) ),
|
66
|
+
Digest::MD5.hexdigest( File.read( "#{path}_sufix.system.png" ) )
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_shot_system_without_sufix
|
72
|
+
in_tmpdir do |tmpdir|
|
73
|
+
client = stub( :capture_screenshot_to_string => read_fixture( "screenshot.base64" ) )
|
74
|
+
path = "#{tmpdir}/myfile"
|
75
|
+
|
76
|
+
BrowserShooter::Commander.shot_system( client, path, nil )
|
77
|
+
|
78
|
+
assert_equal(
|
79
|
+
Digest::MD5.hexdigest( Base64.decode64( read_fixture( "screenshot.base64" ) ) ),
|
80
|
+
Digest::MD5.hexdigest( File.read( "#{path}.system.png" ) )
|
81
|
+
)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_pause
|
86
|
+
Kernel.expects( :sleep ).with( 1 )
|
87
|
+
BrowserShooter::Commander.pause( 1 )
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
class ConfiguratorTest < Test::Unit::TestCase
|
4
|
+
def test_load_config
|
5
|
+
BrowserShooter::Configurator.expects( :timestamp ).returns( "timestamp" )
|
6
|
+
FileUtils.expects( :mkdir_p ).with( "/shoots-path/timestamp" )
|
7
|
+
FileUtils.expects( :mkdir ).with( "/shoots-path/timestamp/shots" )
|
8
|
+
FileUtils.expects( :mkdir ).with( "/shoots-path/timestamp/logs" )
|
9
|
+
|
10
|
+
config = BrowserShooter::Configurator.load_config( "#{FIXTURES}/config_simple.yml" )
|
11
|
+
|
12
|
+
assert_equal( "/shoots-path/timestamp", config["output_path"] )
|
13
|
+
assert_equal( "script-one", config["scripts"]["script-one"] )
|
14
|
+
assert_equal( "browser-one", config["browsers"]["browser-one"] )
|
15
|
+
end
|
16
|
+
end
|
data/test/driver_test.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
class DriverTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_run_script_on_browser
|
6
|
+
browser = {
|
7
|
+
"name" => "browser-name",
|
8
|
+
"host" => "browser-host",
|
9
|
+
"port" => "browser-port",
|
10
|
+
"browser" => "browser-browser"
|
11
|
+
}
|
12
|
+
|
13
|
+
script = {
|
14
|
+
"name" => "script-name",
|
15
|
+
"url" => "script-url",
|
16
|
+
"commands" => "one\ntwo\nthree"
|
17
|
+
}
|
18
|
+
|
19
|
+
expected_opts = {
|
20
|
+
:host => "browser-host",
|
21
|
+
:port => "browser-port",
|
22
|
+
:browser => "browser-browser",
|
23
|
+
:url => "script-url",
|
24
|
+
:timeout_in_seconds => 40
|
25
|
+
}
|
26
|
+
|
27
|
+
client = Object.new
|
28
|
+
client.expects( :start_new_browser_session )
|
29
|
+
client.expects( :close_current_browser_session )
|
30
|
+
|
31
|
+
Selenium::Client::Driver.expects( :new ).with( expected_opts ).returns( client )
|
32
|
+
|
33
|
+
BrowserShooter::Commander.expects( :execute ).with( "one", client, "shoots-path/script-name_browser-name")
|
34
|
+
BrowserShooter::Commander.expects( :execute ).with( "two", client, "shoots-path/script-name_browser-name")
|
35
|
+
BrowserShooter::Commander.expects( :execute ).with( "three", client, "shoots-path/script-name_browser-name")
|
36
|
+
|
37
|
+
BrowserShooter::Driver.run_script_on_browser(script, browser, "shoots-path")
|
38
|
+
end
|
39
|
+
end
|
data/test/fixtures/config.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
output_path: "/tmp/shoots"
|
2
2
|
|
3
3
|
scripts:
|
4
4
|
google:
|
@@ -7,12 +7,11 @@ scripts:
|
|
7
7
|
commands: |
|
8
8
|
open "/"
|
9
9
|
window_maximize
|
10
|
-
shot
|
10
|
+
shot 01_before
|
11
11
|
type "id=lst-ib", "fernando guillen"
|
12
12
|
click "name=btnG", wait_for :page
|
13
13
|
pause 3
|
14
|
-
shot
|
15
|
-
|
14
|
+
shot 02_after
|
16
15
|
|
17
16
|
miniclip:
|
18
17
|
name: "miniclip"
|
@@ -22,19 +21,6 @@ scripts:
|
|
22
21
|
window_maximize
|
23
22
|
shot
|
24
23
|
|
25
|
-
brandengage:
|
26
|
-
name: "brandengage"
|
27
|
-
url: "http://staging.iframe.sponsorpay.com"
|
28
|
-
commands: |
|
29
|
-
open "/test/brandengage.html"
|
30
|
-
window_maximize
|
31
|
-
click "link=be_1372_dedicated"
|
32
|
-
pause 5
|
33
|
-
get_alert
|
34
|
-
click "link=sp.showVideo();"
|
35
|
-
pause 5
|
36
|
-
shot
|
37
|
-
|
38
24
|
browsers:
|
39
25
|
windows-firefox:
|
40
26
|
name: "windows-firefox"
|
Binary file
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,30 @@
|
|
1
1
|
require "test/unit"
|
2
|
+
require "mocha"
|
2
3
|
require_relative "../lib/browser_shooter"
|
3
4
|
|
4
|
-
|
5
|
+
module TestHelper
|
6
|
+
FIXTURES = File.expand_path( "#{File.dirname(__FILE__)}/fixtures" )
|
7
|
+
|
8
|
+
def read_fixture( fixture_name )
|
9
|
+
File.read( "#{FIXTURES}/#{fixture_name}" )
|
10
|
+
end
|
11
|
+
|
12
|
+
def in_tmpdir
|
13
|
+
path = File.expand_path "#{Dir.tmpdir}/#{Time.now.to_i}_#{rand(1000)}/"
|
14
|
+
FileUtils.mkdir_p( path )
|
15
|
+
|
16
|
+
yield( path )
|
17
|
+
|
18
|
+
ensure
|
19
|
+
FileUtils.rm_rf( path ) if File.exists?( path )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Test::Unit::TestCase
|
24
|
+
include TestHelper
|
25
|
+
|
26
|
+
def setup
|
27
|
+
BrowserShooter::Logger.stubs( :log )
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
metadata
CHANGED
@@ -1,106 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: browser_shooter
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
version: 0.0.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Fernando Guillen
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-02 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: bundler
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70249375547000 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 0
|
31
|
-
- 0
|
32
|
-
- rc
|
33
|
-
- 6
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 1.0.0.rc.6
|
35
22
|
type: :development
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rake
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *70249375547000
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70249375546500 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
- 9
|
48
|
-
- 2
|
49
|
-
- 2
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
50
32
|
version: 0.9.2.2
|
51
33
|
type: :development
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: selenium-webdriver
|
55
34
|
prerelease: false
|
56
|
-
|
35
|
+
version_requirements: *70249375546500
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mocha
|
38
|
+
requirement: &70249375546120 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70249375546120
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: selenium-webdriver
|
49
|
+
requirement: &70249375545660 !ruby/object:Gem::Requirement
|
57
50
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
- 0
|
63
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
64
55
|
type: :runtime
|
65
|
-
version_requirements: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
|
-
name: selenium
|
68
56
|
prerelease: false
|
69
|
-
|
57
|
+
version_requirements: *70249375545660
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: selenium
|
60
|
+
requirement: &70249375545240 !ruby/object:Gem::Requirement
|
70
61
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
- 0
|
76
|
-
version: "0"
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
77
66
|
type: :runtime
|
78
|
-
version_requirements: *id004
|
79
|
-
- !ruby/object:Gem::Dependency
|
80
|
-
name: selenium-client
|
81
67
|
prerelease: false
|
82
|
-
|
68
|
+
version_requirements: *70249375545240
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: selenium-client
|
71
|
+
requirement: &70249375544820 !ruby/object:Gem::Requirement
|
83
72
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
- 0
|
89
|
-
version: "0"
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
90
77
|
type: :runtime
|
91
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70249375544820
|
92
80
|
description: Selenium RC wraper to create browser screenshots
|
93
|
-
email:
|
81
|
+
email:
|
94
82
|
- fguillen.mail@gmail.com
|
95
|
-
executables:
|
83
|
+
executables:
|
96
84
|
- browser_shooter
|
97
85
|
extensions: []
|
98
|
-
|
99
86
|
extra_rdoc_files: []
|
100
|
-
|
101
|
-
files:
|
87
|
+
files:
|
102
88
|
- .gitignore
|
103
89
|
- .rvmrc.example
|
90
|
+
- .travis.yml
|
104
91
|
- Gemfile
|
105
92
|
- README.md
|
106
93
|
- Rakefile
|
@@ -109,47 +96,53 @@ files:
|
|
109
96
|
- examples/config1.yml
|
110
97
|
- examples/config2.yml
|
111
98
|
- examples/config3.yml
|
99
|
+
- examples/config4.yml
|
100
|
+
- examples/config5.yml
|
112
101
|
- lib/browser_shooter.rb
|
113
102
|
- lib/browser_shooter/commander.rb
|
103
|
+
- lib/browser_shooter/configurator.rb
|
114
104
|
- lib/browser_shooter/driver.rb
|
105
|
+
- lib/browser_shooter/log_exporter.rb
|
115
106
|
- lib/browser_shooter/logger.rb
|
116
107
|
- lib/browser_shooter/version.rb
|
117
108
|
- test/browser_shooter_test.rb
|
109
|
+
- test/commander_test.rb
|
110
|
+
- test/configurator_test.rb
|
111
|
+
- test/driver_test.rb
|
118
112
|
- test/fixtures/config.yml
|
113
|
+
- test/fixtures/config_simple.yml
|
114
|
+
- test/fixtures/screenshot.base64
|
119
115
|
- test/test_helper.rb
|
120
|
-
has_rdoc: true
|
121
116
|
homepage: https://github.com/fguillen/BrowserShooter
|
122
117
|
licenses: []
|
123
|
-
|
124
118
|
post_install_message:
|
125
119
|
rdoc_options: []
|
126
|
-
|
127
|
-
require_paths:
|
120
|
+
require_paths:
|
128
121
|
- lib
|
129
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
123
|
none: false
|
131
|
-
requirements:
|
132
|
-
- -
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
|
135
|
-
|
136
|
-
version: "0"
|
137
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
129
|
none: false
|
139
|
-
requirements:
|
140
|
-
- -
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
|
143
|
-
- 0
|
144
|
-
version: "0"
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
145
134
|
requirements: []
|
146
|
-
|
147
135
|
rubyforge_project: browser_shooter
|
148
|
-
rubygems_version: 1.
|
136
|
+
rubygems_version: 1.8.15
|
149
137
|
signing_key:
|
150
138
|
specification_version: 3
|
151
139
|
summary: Selenium RC wraper to create browser screenshots
|
152
|
-
test_files:
|
140
|
+
test_files:
|
153
141
|
- test/browser_shooter_test.rb
|
142
|
+
- test/commander_test.rb
|
143
|
+
- test/configurator_test.rb
|
144
|
+
- test/driver_test.rb
|
154
145
|
- test/fixtures/config.yml
|
146
|
+
- test/fixtures/config_simple.yml
|
147
|
+
- test/fixtures/screenshot.base64
|
155
148
|
- test/test_helper.rb
|