xautobrowse 0.1.0 → 0.1.1
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
- checksums.yaml.gz.sig +3 -1
- data/lib/xautobrowse.rb +35 -26
- data.tar.gz.sig +0 -0
- metadata +2 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bd962c21e206a637724b51740ca2621b573398a
|
4
|
+
data.tar.gz: fa0c8af387436e9ce83e23622acc971ae1eff9ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfceccbff97cefc1b71dbcc6cf29d26e80452c4540a096544f32b577f8ebb7e6b9851d80112e87895daa0621f69078d577fa9cccb62d91ca5e7cd90923e18161
|
7
|
+
data.tar.gz: f245d6273bea4465e09a20d407cf6142a51ac02cf7b3e5eb55d9ac9816b22869f30a46d37ed45c601e33a0c2f50a962c802d6327a626d234d088480d7c5109cb
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
|
1
|
+
G��t�_٧I�V_�]� D�
|
2
|
+
|
3
|
+
���R��������?E�2^R�[��'�+��ߚ�ZN���?G��~��#���H�BrYNћJ�fB��@�]���u�t4Q��ŮG���e3�i�E"K���4�z�ص]�m����3W�D5���ס��9�<rQ���cNt��D>�� �H����v�0�μ,�փ�^��������:��ׯ�ʯ�+�)rdF���x�c`��NY������WԤp��Z��-[y��
|
data/lib/xautobrowse.rb
CHANGED
@@ -5,6 +5,12 @@
|
|
5
5
|
# description: Runs on an X Windows system (e.g. Debian running LXDE)
|
6
6
|
# Primarily tested using Firefox (52.6.0 (64-bit)) on Debian.
|
7
7
|
|
8
|
+
|
9
|
+
# modifications
|
10
|
+
|
11
|
+
# 28 Jan 2018: feature: Chromium is now supported
|
12
|
+
|
13
|
+
|
8
14
|
require 'wmctrl'
|
9
15
|
require 'nokorexi'
|
10
16
|
require 'clipboard'
|
@@ -16,14 +22,15 @@ require "xdo/xwindow"
|
|
16
22
|
|
17
23
|
class XAutoBrowse
|
18
24
|
|
19
|
-
def initialize(
|
25
|
+
def initialize(browser= :firefox, debug: false)
|
20
26
|
|
21
|
-
@debug = debug
|
27
|
+
@browser, @debug = browser, debug
|
22
28
|
|
23
29
|
@wm = WMCtrl.instance
|
24
|
-
spawn(
|
25
|
-
sleep
|
26
|
-
|
30
|
+
spawn(browser.to_s)
|
31
|
+
sleep 5
|
32
|
+
|
33
|
+
id = XDo::XWindow.wait_for_window(browser)
|
27
34
|
xwin = XDo::XWindow.new(id)
|
28
35
|
title = xwin.title
|
29
36
|
puts 'title: ' + title.inspect if @debug
|
@@ -32,7 +39,7 @@ class XAutoBrowse
|
|
32
39
|
|
33
40
|
a = @wm.list_windows true
|
34
41
|
puts 'a: ' + a.inspect if @debug
|
35
|
-
r = a.find {|x| x[:title] =~ /#{
|
42
|
+
r = a.reverse.find {|x| x[:title] =~ /#{browser}$/i}
|
36
43
|
@id = r[:id]
|
37
44
|
|
38
45
|
@x, @y, @width, @height = *r[:geometry]
|
@@ -57,6 +64,7 @@ class XAutoBrowse
|
|
57
64
|
|
58
65
|
activate()
|
59
66
|
sleep 2
|
67
|
+
|
60
68
|
if block_given? then
|
61
69
|
yield(self)
|
62
70
|
end
|
@@ -71,9 +79,8 @@ class XAutoBrowse
|
|
71
79
|
sleep 0.5
|
72
80
|
XDo::Keyboard.ctrl_l
|
73
81
|
sleep 0.5
|
74
|
-
|
75
|
-
|
76
|
-
sleep 5
|
82
|
+
enter(url)
|
83
|
+
sleep 4
|
77
84
|
|
78
85
|
end
|
79
86
|
|
@@ -89,25 +96,19 @@ class XAutoBrowse
|
|
89
96
|
|
90
97
|
def text_field(klass: nil, id: nil, name: nil, value: '')
|
91
98
|
|
92
|
-
|
93
|
-
|
99
|
+
console = @browser == :firefox ? :ctrl_shift_k : :ctrl_shift_i
|
100
|
+
XDo::Keyboard.send console # web console
|
94
101
|
|
95
|
-
|
96
|
-
|
102
|
+
sleep 3
|
103
|
+
|
104
|
+
cmd = if klass then
|
105
|
+
"r = document.querySelector('#{klass}')"
|
97
106
|
elsif id then
|
98
|
-
|
107
|
+
"r = document.getElementById(\"#{id}\")"
|
99
108
|
end
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
XDo::Keyboard.type("r.value = \"\"")
|
104
|
-
sleep 2
|
105
|
-
XDo::Keyboard.return
|
106
|
-
sleep 1
|
107
|
-
XDo::Keyboard.type("r.focus()")
|
108
|
-
sleep 2
|
109
|
-
XDo::Keyboard.return
|
110
|
-
sleep 2
|
109
|
+
|
110
|
+
[cmd, "r.value = \"\"", "r.focus()"].each {|x| enter x}
|
111
|
+
|
111
112
|
XDo::Keyboard.ctrl_shift_i # toggle tools
|
112
113
|
sleep 2
|
113
114
|
XDo::Keyboard.type(value)
|
@@ -131,6 +132,14 @@ class XAutoBrowse
|
|
131
132
|
sleep 0.5
|
132
133
|
XDo::Keyboard.ctrl_u # View source code
|
133
134
|
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
def enter(s)
|
139
|
+
XDo::Keyboard.type(s)
|
140
|
+
sleep 0.8
|
141
|
+
XDo::Keyboard.return
|
142
|
+
sleep 1
|
143
|
+
end
|
134
144
|
|
135
145
|
end
|
136
|
-
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xautobrowse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -142,6 +142,5 @@ rubyforge_project:
|
|
142
142
|
rubygems_version: 2.6.13
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
|
-
summary: A poor man's web automation tool primarily for
|
146
|
-
windows system.
|
145
|
+
summary: A poor man's web automation tool primarily for Firefox in an X windows system.
|
147
146
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|