browsed 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/browsed/client.rb +24 -18
- data/lib/browsed/firefox.rb +5 -3
- 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: 5e4e1bad4aea31f419ea850bb4ccec0b8f8f2691edc62a8ba19eda0fb19b3110
|
4
|
+
data.tar.gz: 7d4c642d6c6cccc3e334dddb9e77604d0ad16987e13bfe1ae26c381dcdce7b49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aba65bc0ca76bbba834a7947dbd5c1100c168d9bb969bbc343b89280af7150829c6e2102648fc1a18b9e589fad78f91a639b9fc6789f9006fbf56e6d58bcb23
|
7
|
+
data.tar.gz: 6f6876c72c3a38723b5cd707ae087d4409985c31196462a3e7b7bc378d785e0a4723ffaf5d00d4f003a2189d597ed569aa1dc285f64956e57804d68abb8c86e1
|
data/Gemfile.lock
CHANGED
data/lib/browsed/client.rb
CHANGED
@@ -45,19 +45,7 @@ module Browsed
|
|
45
45
|
|
46
46
|
def setup_capybara(driver_options: {}, retries: 3)
|
47
47
|
if can_start_new_process?
|
48
|
-
|
49
|
-
register_poltergeist_driver(driver_options: driver_options)
|
50
|
-
elsif selenium?
|
51
|
-
if firefox_browser?
|
52
|
-
register_firefox_driver(driver_options: driver_options)
|
53
|
-
elsif chrome_browser?
|
54
|
-
self.driver = :selenium_chrome
|
55
|
-
register_chrome_driver(driver_options: driver_options)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
puts "Self.driver: #{self.driver}"
|
60
|
-
puts "Self.browser: #{self.browser}"
|
48
|
+
register_driver!(driver_options)
|
61
49
|
|
62
50
|
Capybara.default_driver = self.driver
|
63
51
|
Capybara.javascript_driver = self.driver
|
@@ -78,7 +66,30 @@ module Browsed
|
|
78
66
|
Launchy.open path if development?
|
79
67
|
end
|
80
68
|
|
69
|
+
def reset_session!
|
70
|
+
self.session.reset_session!
|
71
|
+
end
|
72
|
+
|
73
|
+
def terminate_session!
|
74
|
+
self.session.reset_session!
|
75
|
+
self.session.driver.quit
|
76
|
+
self.session = nil
|
77
|
+
end
|
78
|
+
|
81
79
|
private
|
80
|
+
def register_driver!(driver_options = {})
|
81
|
+
if poltergeist?
|
82
|
+
register_poltergeist_driver(driver_options: driver_options)
|
83
|
+
elsif selenium?
|
84
|
+
if firefox_browser?
|
85
|
+
register_firefox_driver(driver_options: driver_options)
|
86
|
+
elsif chrome_browser?
|
87
|
+
self.driver = :selenium_chrome
|
88
|
+
register_chrome_driver(driver_options: driver_options)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
82
93
|
def poltergeist?
|
83
94
|
self.driver.to_sym.eql?(:poltergeist)
|
84
95
|
end
|
@@ -103,11 +114,6 @@ module Browsed
|
|
103
114
|
self.environment.eql?(env)
|
104
115
|
end
|
105
116
|
|
106
|
-
def terminate_session!(retries: 3)
|
107
|
-
self.session.driver.quit
|
108
|
-
self.session = nil
|
109
|
-
end
|
110
|
-
|
111
117
|
# User Agents
|
112
118
|
def set_user_agent(user_agent)
|
113
119
|
if !user_agent.to_s.empty?
|
data/lib/browsed/firefox.rb
CHANGED
@@ -4,12 +4,14 @@ module Browsed
|
|
4
4
|
private
|
5
5
|
def register_firefox_driver(driver_options: {}, timeout: 60, debug: false)
|
6
6
|
download_path = driver_options.fetch(:download_path, self.configuration.download_path)
|
7
|
-
|
7
|
+
private_browsing = driver_options.fetch(:private_browsing, false)
|
8
8
|
|
9
9
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
if private_browsing
|
12
|
+
profile["browser.privatebrowsing.autostart"] = true
|
13
|
+
end
|
14
|
+
|
13
15
|
unless download_path.to_s.empty?
|
14
16
|
profile["browser.download.useDownloadDir"] = true
|
15
17
|
profile["browser.download.dir"] = download_directory
|
data/lib/browsed/version.rb
CHANGED