browsed 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/browsed/chrome.rb +5 -5
- data/lib/browsed/client.rb +16 -13
- data/lib/browsed/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61e83765b6257c39cd97be1c3764a20bb20e90b6ce602c94d693b0fb4444bf64
|
4
|
+
data.tar.gz: 8f747af9a52257cd1a05aecfddbd81fc714e76253472eba5ef7724a6dce1e10f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 666a4dd2ace58b39da9b7132493c0f64dc605fb50de3db3363b21f18caaa643be3cc33321c6ce5e94c372735e998e8ba611262a683591351f3512617f125ddee
|
7
|
+
data.tar.gz: 4b191391235827932b9b8e16942802757424bfb77f25b0a9076243ba8fa520f9da87a3faf293c29e321be0c8e64503d375fd5901344c480e5e744b8739837399
|
data/lib/browsed/chrome.rb
CHANGED
@@ -4,17 +4,17 @@ module Browsed
|
|
4
4
|
private
|
5
5
|
def register_chrome_driver(options: {}, timeout: 60, debug: false)
|
6
6
|
headless = options.fetch(:headless, false)
|
7
|
-
|
8
|
-
height = options.fetch(:height, 1080)
|
7
|
+
resolution = options.fetch(:resolution, [1366,768])
|
9
8
|
profile = Selenium::WebDriver::Chrome::Profile.new
|
10
9
|
|
11
10
|
profile["user-agent"] = self.user_agent unless self.user_agent.to_s.empty?
|
12
11
|
|
13
12
|
proxy_options = chrome_proxy_options
|
14
13
|
capabilities = !proxy_options.nil? ? Selenium::WebDriver::Remote::Capabilities.chrome(proxy: proxy_options) : {}
|
15
|
-
args = %
|
16
|
-
args = args | %
|
17
|
-
|
14
|
+
args = %w(disable-popup-blocking)
|
15
|
+
args = args | %W(window-size=#{resolution.first},#{resolution.last}) if resolution && resolution.any? && resolution.size.eql?(2)
|
16
|
+
args = args | %w(headless disable-gpu) if headless
|
17
|
+
|
18
18
|
options = Selenium::WebDriver::Chrome::Options.new(profile: profile, args: args)
|
19
19
|
|
20
20
|
Capybara.register_driver self.driver do |app|
|
data/lib/browsed/client.rb
CHANGED
@@ -72,11 +72,16 @@ module Browsed
|
|
72
72
|
def resize!(res = nil)
|
73
73
|
res ||= self.resolution
|
74
74
|
|
75
|
-
if res && res.size.eql?(2) &&
|
75
|
+
if res && res.size.eql?(2) && resizable_browser?(self.driver) # 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
|
79
79
|
|
80
|
+
def resizable_browser?(driver)
|
81
|
+
non_resizable = [:poltergeist, :selenium_chrome, :selenium_chrome_headless]
|
82
|
+
!non_resizable.include?(driver.to_sym)
|
83
|
+
end
|
84
|
+
|
80
85
|
def reset_session!
|
81
86
|
self.session.reset_session!
|
82
87
|
end
|
@@ -104,18 +109,16 @@ module Browsed
|
|
104
109
|
def register_driver!(options = {})
|
105
110
|
if poltergeist?
|
106
111
|
register_poltergeist_driver(options: options)
|
107
|
-
elsif
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
register_chrome_driver(options: options.merge(headless: true))
|
118
|
-
end
|
112
|
+
elsif firefox_browser?
|
113
|
+
register_firefox_driver(options: options)
|
114
|
+
elsif firefox_headless_browser?
|
115
|
+
register_firefox_driver(options: options.merge(headless: true))
|
116
|
+
elsif chrome_browser?
|
117
|
+
self.driver = :selenium_chrome
|
118
|
+
register_chrome_driver(options: options.merge(resolution: self.resolution))
|
119
|
+
elsif chrome_headless_browser?
|
120
|
+
self.driver = :selenium_chrome_headless
|
121
|
+
register_chrome_driver(options: options.merge(resolution: self.resolution, headless: true))
|
119
122
|
end
|
120
123
|
end
|
121
124
|
|
data/lib/browsed/version.rb
CHANGED