omnibrowser 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/basic_browser.rb +75 -0
- data/lib/omni_browser.rb +5 -35
- data/lib/omni_browser/action_logging.rb +5 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4549c62b32e8df4e719f492362a4be13ec5ac06f
|
4
|
+
data.tar.gz: 14a1152ec1a2fc05bc1ac57278079355225aa3a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc49d1acefc932f0c82d77726ad11ada77bb4aeff700c359d71fadb90597131c77dcb6d09c1b74bbe0a48958f5794b9f39eb3ec9d857aab2d104f307d43f01ab
|
7
|
+
data.tar.gz: ed61f9aa7f753ca37056450aad446042475603855d26ec2fd77502766cd43ea387501e04d34d08620085717c004716d36568e132fd12a906e5827a4456da68af
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'flex_core'
|
2
|
+
|
3
|
+
class BasicBrowser
|
4
|
+
|
5
|
+
FIREFOX_41 = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'
|
6
|
+
|
7
|
+
CHROME = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
|
8
|
+
|
9
|
+
def initialize (*configs)
|
10
|
+
|
11
|
+
@profile = Selenium::WebDriver::Firefox::Profile.new
|
12
|
+
@profile['javascript.enabled'] = false if configs.include?(:no_java)
|
13
|
+
@profile['general.useragent.override'] =
|
14
|
+
case
|
15
|
+
when configs.include?(:firefox_41)
|
16
|
+
FIREFOX_41
|
17
|
+
else
|
18
|
+
CHROME
|
19
|
+
end
|
20
|
+
|
21
|
+
@browser = Watir::Browser.new(:firefox, profile: @profile)
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def resize (width, height = nil)
|
26
|
+
height = width if height.nil?
|
27
|
+
@browser.window.resize_to(width, height)
|
28
|
+
end
|
29
|
+
|
30
|
+
def move (x, y)
|
31
|
+
@browser.window.move_to(x, y)
|
32
|
+
end
|
33
|
+
|
34
|
+
def zoom_out (times)
|
35
|
+
times.times do
|
36
|
+
@browser.send_keys([:command, :subtract])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def position
|
41
|
+
@browser.windows.first.position.to_a
|
42
|
+
end
|
43
|
+
|
44
|
+
def size
|
45
|
+
@browser.windows.first.size.to_a
|
46
|
+
end
|
47
|
+
|
48
|
+
def method_missing (method, *args)
|
49
|
+
|
50
|
+
nav_methods = [:goto, :refresh, :back]
|
51
|
+
|
52
|
+
begin
|
53
|
+
result = @browser.send(method, *args)
|
54
|
+
rescue Timeout::Error => _
|
55
|
+
sputs 'page timed out'
|
56
|
+
@browser.stop
|
57
|
+
@browser.refresh
|
58
|
+
end
|
59
|
+
|
60
|
+
sleep(0.88)
|
61
|
+
lprint '.' if method.is_in?(nav_methods)
|
62
|
+
|
63
|
+
result
|
64
|
+
end
|
65
|
+
|
66
|
+
def save_html (path)
|
67
|
+
path = path
|
68
|
+
path << '.html' unless path =~ /.+\.html\z/
|
69
|
+
|
70
|
+
file = File.open(path, 'w')
|
71
|
+
file.puts @browser.html
|
72
|
+
file.close
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/lib/omni_browser.rb
CHANGED
@@ -6,11 +6,13 @@ require 'omni_browser/website'
|
|
6
6
|
require 'watir-webdriver'
|
7
7
|
require 'watir-webdriver/extensions/alerts'
|
8
8
|
|
9
|
-
|
9
|
+
require_relative 'basic_browser'
|
10
10
|
|
11
|
-
|
11
|
+
class BasicBrowser
|
12
12
|
|
13
|
-
|
13
|
+
end
|
14
|
+
|
15
|
+
class OmniBrowser < BasicBrowser
|
14
16
|
|
15
17
|
attr_reader :database, :config, :logging_db, :domains_db, :ip_db
|
16
18
|
attr_accessor :tunnel, :allowance, :my_ip
|
@@ -59,29 +61,6 @@ class OmniBrowser
|
|
59
61
|
@dom_id = nil
|
60
62
|
end
|
61
63
|
|
62
|
-
def resize (width, height = nil)
|
63
|
-
height = width if height.nil?
|
64
|
-
@browser.window.resize_to(width, height)
|
65
|
-
end
|
66
|
-
|
67
|
-
def move (x, y)
|
68
|
-
@browser.window.move_to(x, y)
|
69
|
-
end
|
70
|
-
|
71
|
-
def zoom_out (times)
|
72
|
-
times.times do
|
73
|
-
@browser.send_keys([:command, :subtract])
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def position
|
78
|
-
@browser.windows.first.position.to_a
|
79
|
-
end
|
80
|
-
|
81
|
-
def size
|
82
|
-
@browser.windows.first.size.to_a
|
83
|
-
end
|
84
|
-
|
85
64
|
def method_missing (method, *args)
|
86
65
|
if [:goto, :refresh, :back].include?(method)
|
87
66
|
save_domain
|
@@ -143,13 +122,4 @@ class OmniBrowser
|
|
143
122
|
@browser.url.scan(/[^\/]+/)[1].strip
|
144
123
|
end
|
145
124
|
|
146
|
-
def save_html (path)
|
147
|
-
path = path
|
148
|
-
path << '.html' unless path =~ /.+\.html\z/
|
149
|
-
|
150
|
-
file = File.open(path, 'w')
|
151
|
-
file.puts @browser.html
|
152
|
-
file.close
|
153
|
-
end
|
154
|
-
|
155
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omnibrowser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Lai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flex_pg
|
@@ -58,6 +58,7 @@ executables: []
|
|
58
58
|
extensions: []
|
59
59
|
extra_rdoc_files: []
|
60
60
|
files:
|
61
|
+
- lib/basic_browser.rb
|
61
62
|
- lib/omni_browser.rb
|
62
63
|
- lib/omni_browser/action_logging.rb
|
63
64
|
- lib/omni_browser/action_logging/watir_mods.rb
|
@@ -82,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
83
|
version: '0'
|
83
84
|
requirements: []
|
84
85
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.6.1
|
86
87
|
signing_key:
|
87
88
|
specification_version: 4
|
88
89
|
summary: A powerful automated browser
|