superbot 0.1.3 → 0.1.4.rc1
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/superbot/capybara/convert.rb +2 -1
- data/lib/superbot/capybara/runner.rb +33 -34
- data/lib/superbot/version.rb +1 -1
- data/lib/superbot/web.rb +7 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f96f7642c6913a2137b12f40ecefa344b49b345fa112de19cd5ae284c88ea006
|
4
|
+
data.tar.gz: afd49aafb562eb0ddd366a8ce6fb13a75faede33b125d35bed576dd60e407322
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5616bb9d61f728884c6b8b688850e25c2ea4c6777ff9a9756aa64f6a9e7f715f98290c58ca36f9d05606fcbd44af0f7a4e4c033a51c4cd686e863689a7371c6d
|
7
|
+
data.tar.gz: 73df24e55278661370984c2c73bd8cb90f06380fd4e13514dce9771ba472d6f7a4a37bb38a726e4b5503920ec6baf0e23ae5f9ae9f1ed130f1b73e84d8f21fa1
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ module Superbot
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
converted_json
|
15
|
+
converted_json
|
16
16
|
end
|
17
17
|
|
18
18
|
attr_accessor :json
|
@@ -26,6 +26,7 @@ module Superbot
|
|
26
26
|
when 'scroll' then
|
27
27
|
"page.execute_script('window.scrollBy(0,' + (page.execute_script('return document.body.scrollHeight') * #{action[:amountPercent]} / 100).to_s + ')')"
|
28
28
|
when 'resolution' then "page.driver.browser.manage.window.resize_to(#{action[:resolution].join(',')})"
|
29
|
+
when 'has-text' then "page.assert_text('#{action[:text]}')"
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
@@ -5,59 +5,58 @@ require 'kommando'
|
|
5
5
|
module Superbot
|
6
6
|
module Capybara
|
7
7
|
class Runner
|
8
|
-
def
|
9
|
-
|
8
|
+
def self.run(script)
|
9
|
+
new.run(script)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def run(script)
|
13
|
+
create_runner
|
14
|
+
runner.in.writeln({ eval: script }.to_json)
|
14
15
|
end
|
15
16
|
|
16
|
-
def
|
17
|
-
|
17
|
+
def rerun(script)
|
18
|
+
runner.in.writeln({ eval: script }.to_json)
|
18
19
|
end
|
19
20
|
|
21
|
+
def kill_session
|
22
|
+
runner&.kill
|
23
|
+
rescue Timeout::Error
|
24
|
+
p # do nothing
|
25
|
+
ensure
|
26
|
+
@runner = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_accessor :script, :runner, :finished
|
30
|
+
|
20
31
|
private
|
21
32
|
|
22
|
-
|
33
|
+
def create_runner
|
34
|
+
return if runner
|
23
35
|
|
24
|
-
def run_script
|
25
36
|
gem 'superbot-capybara'
|
26
37
|
|
27
|
-
|
28
|
-
k.in.writeln({ eval: script }.to_json)
|
38
|
+
@runner = Kommando.new "sb-capybara"
|
29
39
|
|
30
|
-
finished = false
|
40
|
+
@finished = false
|
31
41
|
|
32
|
-
|
33
|
-
puts "Test succeed"
|
34
|
-
finished = true
|
42
|
+
runner.out.every(/{"type":"ok".*\n/) do
|
43
|
+
puts "Test succeed!"
|
44
|
+
@finished = true
|
35
45
|
end
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
47
|
+
runner.out.every(/{"type":"error".*\n/) do
|
48
|
+
parsed_error = JSON.parse(runner.out.lines.last, symbolize_names: true)
|
49
|
+
puts "Test failed: #{parsed_error[:message]}"
|
50
|
+
@finished = true
|
51
|
+
if parsed_error[:class].start_with?('Selenium::WebDriver::Error')
|
52
|
+
kill_session
|
53
|
+
puts "", "ERROR: Seems like browser session has been closed, try to run test again to create new session"
|
42
54
|
end
|
43
|
-
finished = true
|
44
|
-
end
|
45
|
-
|
46
|
-
k.run_async
|
47
|
-
|
48
|
-
loop do
|
49
|
-
break if finished
|
50
|
-
|
51
|
-
sleep 0.001
|
52
55
|
end
|
53
56
|
|
54
|
-
|
55
|
-
k.kill
|
56
|
-
rescue Timeout::Error
|
57
|
-
p # do nothing
|
58
|
-
end
|
57
|
+
runner.run_async
|
59
58
|
rescue Gem::LoadError
|
60
|
-
|
59
|
+
abort "superbot-capybara not installed"
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
data/lib/superbot/version.rb
CHANGED
data/lib/superbot/web.rb
CHANGED
@@ -13,6 +13,7 @@ module Superbot
|
|
13
13
|
@sinatra.set :silent_sinatra, true
|
14
14
|
@sinatra.set :silent_webrick, true
|
15
15
|
@sinatra.set :silent_access_log, false
|
16
|
+
instance = self
|
16
17
|
|
17
18
|
@sinatra.before do
|
18
19
|
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'
|
@@ -30,10 +31,15 @@ module Superbot
|
|
30
31
|
end
|
31
32
|
|
32
33
|
@sinatra.post "/__superbot/v1/convert" do
|
33
|
-
Superbot::Capybara::Convert.call(request.body.read)
|
34
|
+
converted_script = Superbot::Capybara::Convert.call(request.body.read)
|
35
|
+
instance.capybara_runner.run(converted_script)
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
39
|
+
def capybara_runner
|
40
|
+
@capybara_runner ||= Superbot::Capybara::Runner.new
|
41
|
+
end
|
42
|
+
|
37
43
|
def run!
|
38
44
|
@sinatra.run_async!
|
39
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Superbots
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -308,9 +308,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
308
308
|
version: '0'
|
309
309
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
310
310
|
requirements:
|
311
|
-
- - "
|
311
|
+
- - ">"
|
312
312
|
- !ruby/object:Gem::Version
|
313
|
-
version:
|
313
|
+
version: 1.3.1
|
314
314
|
requirements: []
|
315
315
|
rubyforge_project:
|
316
316
|
rubygems_version: 2.7.6
|