browsed 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d36d1bfa590a1edc3ce949a6138b1dc0191c889c6f5194aee4e40ef61d1f1e0
4
- data.tar.gz: e6b480c46b0e1c2a8b0f92b5a983a7a2a3763b7d7cecb6b5d06427f755012727
3
+ metadata.gz: 567bb6800134cd99a989a974f961778d88c275e295c3b66e1e8890d5543caac1
4
+ data.tar.gz: 72d12642345e43922330e9b46f5400759873ef546aa84684bb5c990eb0a75456
5
5
  SHA512:
6
- metadata.gz: 8bbf86f64ac1ddd7a4fe0f61dda213c81f515e6308196f0872db07232cb144ad6d76935bdd1f74f4a13c88b340f7635a9cfbff6b12afab69016dab906c5adf60
7
- data.tar.gz: 13d870575253ed835f18d356d48c69bd2f303988739a60ff3bd4ad315bd73d9f9d3ce90cf8345e33113fadcc09d954780ed1bbca9f5cc468dea3e53b5b802f75
6
+ metadata.gz: 6dff5ca6dc9fd9a055c6fcd7e3c96d9644ab071d03136df5cd26068338db33b2ec8ee4ce2e9119d4314cf4854bc2b55401c9f6210c6243e9b5150ae3992fa95b
7
+ data.tar.gz: f295827ad9b5acb1b1e1f8707f96d83f3e07a36e7acbf0000b4b042bcc98082e12412bac998eb87882dfdad90ecb2ed515901e254b8deb65fa92331edbd946a5
data/Gemfile.lock CHANGED
@@ -1,50 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- browsed (0.2.0)
4
+ browsed (0.2.1)
5
5
  agents
6
- capybara (~> 3.4, >= 3.4.1)
6
+ capybara (~> 3.15)
7
7
  poltergeist (~> 1.18, >= 1.18.1)
8
- selenium-webdriver (~> 3.13, >= 3.13.1)
8
+ selenium-webdriver (~> 3.141)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- addressable (2.5.2)
13
+ addressable (2.6.0)
14
14
  public_suffix (>= 2.0.2, < 4.0)
15
- agents (0.1.2)
16
- capybara (3.9.0)
15
+ agents (0.1.4)
16
+ capybara (3.15.0)
17
17
  addressable
18
18
  mini_mime (>= 0.1.3)
19
19
  nokogiri (~> 1.8)
20
20
  rack (>= 1.6.0)
21
21
  rack-test (>= 0.6.3)
22
- xpath (~> 3.1)
22
+ regexp_parser (~> 1.2)
23
+ xpath (~> 3.2)
23
24
  childprocess (0.9.0)
24
25
  ffi (~> 1.0, >= 1.0.11)
25
26
  cliver (0.3.2)
26
27
  coderay (1.1.2)
27
28
  diff-lcs (1.3)
28
- ffi (1.9.25)
29
+ ffi (1.10.0)
29
30
  launchy (2.4.3)
30
31
  addressable (~> 2.3)
31
- method_source (0.9.0)
32
+ method_source (0.9.2)
32
33
  mini_mime (1.0.1)
33
- mini_portile2 (2.3.0)
34
- nokogiri (1.8.5)
35
- mini_portile2 (~> 2.3.0)
34
+ mini_portile2 (2.4.0)
35
+ nokogiri (1.10.2)
36
+ mini_portile2 (~> 2.4.0)
36
37
  poltergeist (1.18.1)
37
38
  capybara (>= 2.1, < 4)
38
39
  cliver (~> 0.3.1)
39
40
  websocket-driver (>= 0.2.0)
40
- pry (0.11.3)
41
+ pry (0.12.2)
41
42
  coderay (~> 1.1.0)
42
43
  method_source (~> 0.9.0)
43
44
  public_suffix (3.0.3)
44
- rack (2.0.5)
45
+ rack (2.0.6)
45
46
  rack-test (1.1.0)
46
47
  rack (>= 1.0, < 3)
47
- rake (10.5.0)
48
+ rake (12.3.2)
49
+ regexp_parser (1.3.0)
48
50
  rspec (3.8.0)
49
51
  rspec-core (~> 3.8.0)
50
52
  rspec-expectations (~> 3.8.0)
@@ -59,13 +61,13 @@ GEM
59
61
  rspec-support (~> 3.8.0)
60
62
  rspec-support (3.8.0)
61
63
  rubyzip (1.2.2)
62
- selenium-webdriver (3.14.1)
64
+ selenium-webdriver (3.141.0)
63
65
  childprocess (~> 0.5)
64
66
  rubyzip (~> 1.2, >= 1.2.2)
65
67
  websocket-driver (0.7.0)
66
68
  websocket-extensions (>= 0.1.0)
67
69
  websocket-extensions (0.1.3)
68
- xpath (3.1.0)
70
+ xpath (3.2.0)
69
71
  nokogiri (~> 1.8)
70
72
 
71
73
  PLATFORMS
@@ -73,11 +75,11 @@ PLATFORMS
73
75
 
74
76
  DEPENDENCIES
75
77
  browsed!
76
- bundler (~> 1.16)
78
+ bundler (~> 2.0.1)
77
79
  launchy (~> 2.4, >= 2.4.3)
78
- pry (~> 0.11.3)
79
- rake (~> 10.0)
80
- rspec (~> 3.0)
80
+ pry (~> 0.12.2)
81
+ rake (~> 12.3.2)
82
+ rspec (~> 3.8.0)
81
83
 
82
84
  BUNDLED WITH
83
- 1.16.3
85
+ 2.0.1
data/README.md CHANGED
@@ -21,10 +21,10 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  ```ruby
24
- # driver can be :poltergeist (PhantomJS) or :selenium/:selenium_chrome (Firefox/Chrome)
25
- # browser can be: :phantomjs, :firefox, :chrome
24
+ # driver can be :poltergeist (PhantomJS) or :selenium/:selenium_chrome/:selenium_chrome_headless (Firefox/Chrome)
25
+ # browser can be: :phantomjs, :chrome, :chrome_headless, :firefox, :firefox_headless
26
26
  # device can be :desktop, :phone (iphone/android), :tablet (ipad/android), :iphone, :ipad, :android_phone, :android_tablet
27
- client = Browsed::Client.new(driver: :poltergeist, browser: :phantomjs, device: :desktop)
27
+ client = Browsed::Client.new(driver: :selenium_chrome, browser: :chrome, device: :desktop)
28
28
  ```
29
29
 
30
30
  If you want to use proxies (note that proxy authentication is only possible using Poltergeist/PhantomJS):
data/bin/browse CHANGED
@@ -4,8 +4,8 @@ require "bundler/setup"
4
4
  require "browsed"
5
5
  require "launchy"
6
6
 
7
- driver = :selenium
8
- browser = :firefox
7
+ driver = :selenium_chrome
8
+ browser = :chrome
9
9
 
10
10
  url = "https://whatismyipaddress.com"
11
11
  path = File.expand_path("../../files/#{Time.now.to_i}.png", __FILE__)
@@ -16,14 +16,10 @@ client = Browsed::Client.new(
16
16
  device: :desktop,
17
17
  environment: :development,
18
18
  user_agent: :randomize,
19
- resolution: [1366,768]
19
+ resolution: [1920,1080]
20
20
  )
21
21
 
22
22
  client.resize! # Set resolution
23
-
24
23
  client.session.visit(url)
25
-
26
- if driver.eql?(:poltergeist)
27
- client.session.save_screenshot(path)
28
- client.display_screenshot!(path)
29
- end
24
+ client.session.save_screenshot(path)
25
+ client.display_screenshot!(path)
data/browsed.gemspec CHANGED
@@ -23,16 +23,16 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_dependency "capybara", '~> 3.4', '>= 3.4.1'
26
+ spec.add_dependency "capybara", '~> 3.15'
27
27
  spec.add_dependency "poltergeist", '~> 1.18', '>= 1.18.1'
28
- spec.add_dependency "selenium-webdriver", '~> 3.13', '>= 3.13.1'
28
+ spec.add_dependency "selenium-webdriver", '~> 3.141'
29
29
 
30
30
  spec.add_dependency "agents"
31
31
 
32
- spec.add_development_dependency "bundler", "~> 1.16"
33
- spec.add_development_dependency "rake", "~> 10.0"
34
- spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "bundler", "~> 2.0.1"
33
+ spec.add_development_dependency "rake", "~> 12.3.2"
34
+ spec.add_development_dependency "rspec", "~> 3.8.0"
35
35
 
36
- spec.add_development_dependency "pry", "~> 0.11.3"
36
+ spec.add_development_dependency "pry", "~> 0.12.2"
37
37
  spec.add_development_dependency "launchy", '~> 2.4', '>= 2.4.3'
38
38
  end
@@ -3,13 +3,19 @@ module Browsed
3
3
 
4
4
  private
5
5
  def register_chrome_driver(options: {}, timeout: 60, debug: false)
6
+ headless = options.fetch(:headless, false)
7
+ width = option.fetch(:width, 1920)
8
+ height = options.fetch(:height, 1080)
6
9
  profile = Selenium::WebDriver::Chrome::Profile.new
7
10
 
8
11
  profile["user-agent"] = self.user_agent unless self.user_agent.to_s.empty?
9
12
 
10
13
  proxy_options = chrome_proxy_options
11
14
  capabilities = !proxy_options.nil? ? Selenium::WebDriver::Remote::Capabilities.chrome(proxy: proxy_options) : {}
12
- options = Selenium::WebDriver::Chrome::Options.new(profile: profile)
15
+ args = %W(disable-popup-blocking window-size=#{height},#{width})
16
+ args = args | %w(headless disable-gpu)
17
+ raise args.inspect
18
+ options = Selenium::WebDriver::Chrome::Options.new(profile: profile, args: args)
13
19
 
14
20
  Capybara.register_driver self.driver do |app|
15
21
  Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, desired_capabilities: capabilities)
@@ -9,8 +9,8 @@ module Browsed
9
9
  include Capybara::DSL
10
10
 
11
11
  def initialize(configuration: ::Browsed.configuration,
12
- driver: :poltergeist,
13
- browser: :phantomjs,
12
+ driver: :selenium_chrome,
13
+ browser: :chrome,
14
14
  device: :desktop,
15
15
  proxy: nil,
16
16
  user_agent: nil,
@@ -72,7 +72,7 @@ module Browsed
72
72
  def resize!(res = nil)
73
73
  res ||= self.resolution
74
74
 
75
- if res && res.size.eql?(2) && !self.driver.eql?(:poltergeist) # Resolution for Poltergeist is set in the driver
75
+ if res && res.size.eql?(2) && !self.driver.eql?(:chrome) && !self.driver.eql?(:poltergeist) # Resolutions for Chrome & Poltergeist are set in the driver
76
76
  self.session.current_window.resize_to(res.first, res.last) # [width, height]
77
77
  end
78
78
  end
@@ -112,6 +112,9 @@ module Browsed
112
112
  elsif chrome_browser?
113
113
  self.driver = :selenium_chrome
114
114
  register_chrome_driver(options: options)
115
+ elsif chrome_headless_browser?
116
+ self.driver = :selenium_chrome_headless
117
+ register_chrome_driver(options: options.merge(headless: true))
115
118
  end
116
119
  end
117
120
  end
@@ -136,6 +139,10 @@ module Browsed
136
139
  self.browser.to_sym.eql?(:chrome)
137
140
  end
138
141
 
142
+ def chrome_headless_browser?
143
+ self.browser.to_sym.eql?(:chrome_headless)
144
+ end
145
+
139
146
  def development?
140
147
  in_environment?(:development)
141
148
  end
@@ -1,17 +1,17 @@
1
1
  module Browsed
2
2
  class Configuration
3
3
  attr_accessor :driver, :browser, :environment
4
- attr_accessor :phantomjs_path, :download_path
4
+ attr_accessor :binary_path, :download_path
5
5
  attr_accessor :maximum_processes, :processes_max_ttl
6
6
  attr_accessor :verbose
7
7
 
8
8
  def initialize
9
- self.driver = :poltergeist
10
- self.browser = :phantomjs
9
+ self.driver = :selenium_chrome
10
+ self.browser = :chrome
11
11
 
12
12
  self.environment = :production
13
13
 
14
- self.phantomjs_path = "/usr/local/bin/phantomjs"
14
+ self.binary_path = "/usr/local/bin/phantomjs"
15
15
 
16
16
  self.download_path = nil
17
17
 
@@ -19,7 +19,7 @@ module Browsed
19
19
  phantomjs_options: phantom_opts
20
20
  }
21
21
 
22
- options[:phantomjs] = self.configuration.phantomjs_path if in_environment?(:production)
22
+ options[:phantomjs] = self.configuration.binary_path if in_environment?(:production)
23
23
  options[:window_size] = self.resolution if self.resolution&.any?
24
24
 
25
25
  headers = {}
@@ -1,3 +1,3 @@
1
1
  module Browsed
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browsed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2019-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.4'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 3.4.1
19
+ version: '3.15'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '3.4'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 3.4.1
26
+ version: '3.15'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: poltergeist
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,20 +50,14 @@ dependencies:
56
50
  requirements:
57
51
  - - "~>"
58
52
  - !ruby/object:Gem::Version
59
- version: '3.13'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 3.13.1
53
+ version: '3.141'
63
54
  type: :runtime
64
55
  prerelease: false
65
56
  version_requirements: !ruby/object:Gem::Requirement
66
57
  requirements:
67
58
  - - "~>"
68
59
  - !ruby/object:Gem::Version
69
- version: '3.13'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 3.13.1
60
+ version: '3.141'
73
61
  - !ruby/object:Gem::Dependency
74
62
  name: agents
75
63
  requirement: !ruby/object:Gem::Requirement
@@ -90,56 +78,56 @@ dependencies:
90
78
  requirements:
91
79
  - - "~>"
92
80
  - !ruby/object:Gem::Version
93
- version: '1.16'
81
+ version: 2.0.1
94
82
  type: :development
95
83
  prerelease: false
96
84
  version_requirements: !ruby/object:Gem::Requirement
97
85
  requirements:
98
86
  - - "~>"
99
87
  - !ruby/object:Gem::Version
100
- version: '1.16'
88
+ version: 2.0.1
101
89
  - !ruby/object:Gem::Dependency
102
90
  name: rake
103
91
  requirement: !ruby/object:Gem::Requirement
104
92
  requirements:
105
93
  - - "~>"
106
94
  - !ruby/object:Gem::Version
107
- version: '10.0'
95
+ version: 12.3.2
108
96
  type: :development
109
97
  prerelease: false
110
98
  version_requirements: !ruby/object:Gem::Requirement
111
99
  requirements:
112
100
  - - "~>"
113
101
  - !ruby/object:Gem::Version
114
- version: '10.0'
102
+ version: 12.3.2
115
103
  - !ruby/object:Gem::Dependency
116
104
  name: rspec
117
105
  requirement: !ruby/object:Gem::Requirement
118
106
  requirements:
119
107
  - - "~>"
120
108
  - !ruby/object:Gem::Version
121
- version: '3.0'
109
+ version: 3.8.0
122
110
  type: :development
123
111
  prerelease: false
124
112
  version_requirements: !ruby/object:Gem::Requirement
125
113
  requirements:
126
114
  - - "~>"
127
115
  - !ruby/object:Gem::Version
128
- version: '3.0'
116
+ version: 3.8.0
129
117
  - !ruby/object:Gem::Dependency
130
118
  name: pry
131
119
  requirement: !ruby/object:Gem::Requirement
132
120
  requirements:
133
121
  - - "~>"
134
122
  - !ruby/object:Gem::Version
135
- version: 0.11.3
123
+ version: 0.12.2
136
124
  type: :development
137
125
  prerelease: false
138
126
  version_requirements: !ruby/object:Gem::Requirement
139
127
  requirements:
140
128
  - - "~>"
141
129
  - !ruby/object:Gem::Version
142
- version: 0.11.3
130
+ version: 0.12.2
143
131
  - !ruby/object:Gem::Dependency
144
132
  name: launchy
145
133
  requirement: !ruby/object:Gem::Requirement
@@ -209,8 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
197
  - !ruby/object:Gem::Version
210
198
  version: '0'
211
199
  requirements: []
212
- rubyforge_project:
213
- rubygems_version: 2.7.7
200
+ rubygems_version: 3.0.3
214
201
  signing_key:
215
202
  specification_version: 4
216
203
  summary: 'Browsed: Lightweight Capybara/PhantomJS/Selenium framework'