superbara 0.8.0 → 0.8.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/superbara/chrome.rb +2 -5
- data/lib/superbara/cli.rb +14 -3
- data/lib/superbara/dsl.rb +9 -1
- data/lib/superbara/version.rb +1 -1
- data/lib/superbara.rb +7 -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: b54a0a96ac8a218737403e0ca7fec18fab1f87c8248f7f9ce94d9de0d4441a1e
|
4
|
+
data.tar.gz: 6e48efea3c3f0971709b27e3211427728ef77315d4831e8f3b347c5666065131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70c3466d8bc49ca62cbf1a384580e7e3859d9f982503ef1fa199280a92e0dfc6e2c7d7e5169c45db71455ba62d87dea170e6ebaf22dbc550701228667414f794
|
7
|
+
data.tar.gz: 965c67b7d7bc3ed033c4f375f2964493c9d9887635129bd93f6fad7d3fa1e3afb88aa18bcaa4f85945f2d65e5736069d8e7c21e7c8dd65d39c7df3d62879728d
|
data/Gemfile.lock
CHANGED
data/lib/superbara/chrome.rb
CHANGED
@@ -9,9 +9,6 @@ module Superbara; module Chrome
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.register_drivers
|
12
|
-
chromedriver_path = File.join(Superbara.path, "vendor", "chromedriver", Superbara.platform, "chromedriver")
|
13
|
-
chromedriver_path = "#{chromedriver_path}.exe" if Superbara.platform == "win32"
|
14
|
-
|
15
12
|
options = ::Selenium::WebDriver::Chrome::Options.new
|
16
13
|
options.add_argument 'window-size=1680,1024'
|
17
14
|
options.add_argument 'disable-infobars'
|
@@ -25,7 +22,7 @@ module Superbara; module Chrome
|
|
25
22
|
|
26
23
|
Capybara.register_driver :chrome do
|
27
24
|
Capybara::Selenium::Driver.new(nil,
|
28
|
-
driver_path: chromedriver_path,
|
25
|
+
driver_path: Superbara.chromedriver_path,
|
29
26
|
browser: :chrome,
|
30
27
|
http_client: client,
|
31
28
|
options: options,
|
@@ -48,7 +45,7 @@ module Superbara; module Chrome
|
|
48
45
|
options.add_argument 'disable-gpu'
|
49
46
|
|
50
47
|
Capybara::Selenium::Driver.new(nil,
|
51
|
-
driver_path: chromedriver_path,
|
48
|
+
driver_path: Superbara.chromedriver_path,
|
52
49
|
browser: :chrome,
|
53
50
|
http_client: client,
|
54
51
|
desired_capabilities: capabilities,
|
data/lib/superbara/cli.rb
CHANGED
@@ -47,8 +47,6 @@ wait 3 do
|
|
47
47
|
has_text? 'Example Domain'
|
48
48
|
end
|
49
49
|
|
50
|
-
think 1..3
|
51
|
-
|
52
50
|
click 'a'
|
53
51
|
scroll 50
|
54
52
|
"""
|
@@ -77,6 +75,18 @@ scroll 50
|
|
77
75
|
end
|
78
76
|
end
|
79
77
|
|
78
|
+
target_path = File.expand_path '~/.superbara'
|
79
|
+
target = File.join target_path, "chromedriver"
|
80
|
+
from = File.join Superbara.path, "vendor", "chromedriver", Superbara.platform, "chromedriver"
|
81
|
+
if Superbara.platform == "win32"
|
82
|
+
from << ".exe"
|
83
|
+
target << ".exe"
|
84
|
+
end
|
85
|
+
|
86
|
+
File.unlink target if File.exist? target
|
87
|
+
FileUtils.mkdir_p target_path
|
88
|
+
FileUtils.cp from, target
|
89
|
+
|
80
90
|
case main_command
|
81
91
|
when "start", "run"
|
82
92
|
project_path_or_file_expanded = File.expand_path(ARGV[1])
|
@@ -98,6 +108,7 @@ scroll 50
|
|
98
108
|
exit 1
|
99
109
|
end
|
100
110
|
end
|
111
|
+
|
101
112
|
Pry.start if ENV['SUPERBARA_DEBUG']
|
102
113
|
ctx = nil
|
103
114
|
webapp_thread = nil
|
@@ -114,7 +125,6 @@ scroll 50
|
|
114
125
|
when "shell"
|
115
126
|
Superbara.visual_enable!
|
116
127
|
Superbara.shell_enable!
|
117
|
-
Superbara::Chrome.page_load_strategy = "none"
|
118
128
|
|
119
129
|
unless webapp_thread
|
120
130
|
webapp_thread = Thread.new do
|
@@ -132,6 +142,7 @@ scroll 50
|
|
132
142
|
puts "project: #{Superbara.project_name}"
|
133
143
|
puts ""
|
134
144
|
puts "t action".colorize(:light_black)
|
145
|
+
|
135
146
|
Superbara.start!
|
136
147
|
Superbara.visual_disabled do
|
137
148
|
Superbara.current_context.__superbara_eval "visit 'about:blank'"
|
data/lib/superbara/dsl.rb
CHANGED
@@ -35,6 +35,8 @@ module Superbara; module DSL
|
|
35
35
|
end
|
36
36
|
|
37
37
|
target_path = File.join(Superbara.project_path, filename)
|
38
|
+
|
39
|
+
sleep 0.1 #magically prevents hangs
|
38
40
|
save_screenshot(target_path)
|
39
41
|
end
|
40
42
|
|
@@ -166,7 +168,13 @@ return Array.from(
|
|
166
168
|
end
|
167
169
|
|
168
170
|
def scroll(percentage, duration: 0.4)
|
169
|
-
|
171
|
+
begin
|
172
|
+
outer_height = Capybara.current_session.current_window.session.execute_script "return document.body.scrollHeight"
|
173
|
+
rescue Selenium::WebDriver::Error::UnknownError => ex
|
174
|
+
sleep 0.1
|
175
|
+
retry
|
176
|
+
end
|
177
|
+
|
170
178
|
scroll_y = outer_height / 100 * percentage
|
171
179
|
|
172
180
|
scrolls = (duration / 0.1).floor
|
data/lib/superbara/version.rb
CHANGED
data/lib/superbara.rb
CHANGED
@@ -111,6 +111,12 @@ module Superbara
|
|
111
111
|
sleep (rand(32) * 0.01).round(2)
|
112
112
|
end
|
113
113
|
|
114
|
+
def self.chromedriver_path
|
115
|
+
path = File.join(File.expand_path('~'), ".superbara", "chromedriver")
|
116
|
+
path << ".exe" if Superbara.platform == "win32"
|
117
|
+
path
|
118
|
+
end
|
119
|
+
|
114
120
|
def self.platform
|
115
121
|
require 'rbconfig'
|
116
122
|
cfg = RbConfig::CONFIG
|
@@ -210,7 +216,7 @@ control+c pressed, closing the browser..."
|
|
210
216
|
end
|
211
217
|
end
|
212
218
|
|
213
|
-
Superbara::Chrome.
|
219
|
+
Superbara::Chrome.page_load_strategy = "none"
|
214
220
|
|
215
221
|
Capybara.default_driver = if ENV["CHROME_URL"]
|
216
222
|
:chrome_remote
|