jeffrafter-crocodile 0.4.1 → 0.4.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.3
data/bin/crocodile CHANGED
@@ -9,6 +9,7 @@ if ARGV.size == 0 || ARGV.include?('--help')
9
9
  puts " --script=SCRIPT Execute arbitrary javascript in the window"
10
10
  puts " --control=CODE Execute control code"
11
11
  puts " --timeout=TIMEOUT Stop waiting"
12
+ puts " --browser=BROWSER Use something like *firefox /usr/bin/firefox-bin"
12
13
  puts " --help"
13
14
  exit
14
15
  end
@@ -27,13 +28,15 @@ height = opt "height"
27
28
  script = opt "script"
28
29
  control = opt "control"
29
30
  timeout = opt "timeout"
31
+ browser = opt "browser"
30
32
 
31
33
  options = {}
32
34
  options[:start] = true if ARGV.include? '--start'
33
- options[:stop] = true if ARGV.include? '--start'
35
+ options[:stop] = true if ARGV.include? '--stop'
34
36
  options[:width] = width if width
35
37
  options[:height] = height if height
36
38
  options[:timeout] = timeout if timeout
39
+ options[:browser] = browser if browser
37
40
 
38
41
  # Grab the params
39
42
  params = ARGV.reject{|arg| arg =~ /^--/}
@@ -41,7 +44,7 @@ source = params[0] rescue nil
41
44
  dest = params[1] rescue nil
42
45
  if source.nil? || dest.nil?
43
46
  Crocodile.start if options[:start]
44
- Crocodile.stop if options[:start]
47
+ Crocodile.stop if options[:stop]
45
48
  exit
46
49
  end
47
50
 
data/crocodile.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{crocodile}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Rafter"]
data/lib/crocodile.rb CHANGED
@@ -4,7 +4,7 @@ class Crocodile
4
4
 
5
5
  HOST = "0.0.0.0"
6
6
  PORT = 4444
7
- TIMEOUT = 60
7
+ TIMEOUT = 10
8
8
 
9
9
  def self.start
10
10
  selenium = Selenium::RemoteControl::RemoteControl.new(HOST, PORT, TIMEOUT)
@@ -25,13 +25,16 @@ class Crocodile
25
25
  :host => HOST || options[:host],
26
26
  :port => PORT || options[:port],
27
27
  :timeout_in_second => TIMEOUT || options[:timeout],
28
- :browser => "*firefox",
28
+ :browser => options[:browser] || "*firefox",
29
29
  :url => host)
30
30
  browser.start_new_browser_session
31
31
  browser.open url
32
- browser.get_eval "window.resizeTo(#{options[:width]},#{options[:height]});" if (options[:width] && options[:height])
32
+ browser.wait_for_page_to_load(TIMEOUT || options[:timeout])
33
+ if (options[:width] && options[:height])
34
+ browser.get_eval("window.resizeTo(#{options[:width]},#{options[:height]});")
35
+ end
33
36
  yield browser if block
34
- browser.capture_entire_page_screenshot File.join(File.expand_path('.'), dest), :wait_for => :page
37
+ browser.capture_entire_page_screenshot File.join(File.expand_path('.'), dest), ''
35
38
  browser.close_current_browser_session
36
39
  ensure
37
40
  stop if options[:stop]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeffrafter-crocodile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Rafter