xautobrowse 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bd962c21e206a637724b51740ca2621b573398a
4
- data.tar.gz: fa0c8af387436e9ce83e23622acc971ae1eff9ad
3
+ metadata.gz: d319574fa5c3501f869e6e6300e82b581d70b9ed
4
+ data.tar.gz: 764e5db815a9c363ef05e97455470a5883d474be
5
5
  SHA512:
6
- metadata.gz: dfceccbff97cefc1b71dbcc6cf29d26e80452c4540a096544f32b577f8ebb7e6b9851d80112e87895daa0621f69078d577fa9cccb62d91ca5e7cd90923e18161
7
- data.tar.gz: f245d6273bea4465e09a20d407cf6142a51ac02cf7b3e5eb55d9ac9816b22869f30a46d37ed45c601e33a0c2f50a962c802d6327a626d234d088480d7c5109cb
6
+ metadata.gz: 27f65ee6a3b0b7e5702300b6436de310fbf4adf349cd31e48cd54647f04d9dcb52624cbe4bd2fdee4ab5dbcba84ecc843be38305ec2ee37a5980ee8a9dab01fa
7
+ data.tar.gz: ab1c53b6f81d33bdf14189a3115ff577b5cd828e6ebf7b3c04d422f19cfe18f5139ccb59df5a46338a41f64ca6007ab0155549345196613b2b842f390c83e869
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1 @@
1
- G��t�_٧IV_] 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��
1
+ �C�' �M+������|%4c��3dڽ9� �j���T6h�$t@�-�5�^�H�t��Z$Y������ihO>pRm^���;�4���ȣM���yL"cqVR�{;�����ޟn�.��OW��
data/lib/xautobrowse.rb CHANGED
@@ -8,7 +8,8 @@
8
8
 
9
9
  # modifications
10
10
 
11
- # 28 Jan 2018: feature: Chromium is now supported
11
+ # 28 Jan 2018: feature: Chromium is now supported.
12
+ # A custom accesskey can now be used to jump to an element.
12
13
 
13
14
 
14
15
  require 'wmctrl'
@@ -27,8 +28,7 @@ class XAutoBrowse
27
28
  @browser, @debug = browser, debug
28
29
 
29
30
  @wm = WMCtrl.instance
30
- spawn(browser.to_s)
31
- sleep 5
31
+ spawn(browser.to_s); sleep 5
32
32
 
33
33
  id = XDo::XWindow.wait_for_window(browser)
34
34
  xwin = XDo::XWindow.new(id)
@@ -45,6 +45,15 @@ class XAutoBrowse
45
45
  @x, @y, @width, @height = *r[:geometry]
46
46
 
47
47
  end
48
+
49
+ # custom accesskey (e.g. CTRL+SHIFT+S) typically used to reference an
50
+ # element on the web page
51
+ #
52
+ def accesskey(key)
53
+ XDo::Keyboard.send key.to_sym
54
+ end
55
+
56
+ alias access_key accesskey
48
57
 
49
58
  def activate()
50
59
  @wm.action_window(@id, :activate)
@@ -52,35 +61,52 @@ class XAutoBrowse
52
61
 
53
62
  def copy_source()
54
63
 
55
- view_source()
56
- sleep 3
57
- XDo::Keyboard.ctrl_a # select all
64
+ view_source(); sleep 3
65
+ ctrl_a() # select all
58
66
  sleep 1
59
- XDo::Keyboard.ctrl_c # copy the source code to the clipboard
67
+ ctrl_c() # copy the source code to the clipboard
60
68
 
61
69
  end
62
70
 
71
+ # select all
72
+ #
73
+ def ctrl_a() XDo::Keyboard.ctrl_a end
74
+
75
+ # copy
76
+ #
77
+ def ctrl_c() XDo::Keyboard.ctrl_c end
78
+
79
+ # jump to the location bar
80
+ #
81
+ def ctrl_l() XDo::Keyboard.ctrl_l end
82
+
83
+ # view source code
84
+ #
85
+ def ctrl_u() XDo::Keyboard.ctrl_u end
86
+
87
+ # developer tools
88
+ #
89
+ def ctrl_shift_i() XDo::Keyboard.ctrl_shift_i end
90
+
91
+ # submit a form by pressing return
92
+ #
63
93
  def go()
64
94
 
65
- activate()
66
- sleep 2
67
-
68
95
  if block_given? then
69
- yield(self)
96
+
97
+ activate(); sleep 2
98
+ yield(self)
99
+ carriage_return()
100
+
70
101
  end
71
102
 
72
- XDo::Keyboard.return
73
-
74
103
  end
75
104
 
76
105
  def goto(url)
77
106
 
78
- @wm.action_window(@id, :activate)
79
- sleep 0.5
80
- XDo::Keyboard.ctrl_l
81
- sleep 0.5
82
- enter(url)
83
- sleep 4
107
+ activate(); sleep 0.5
108
+ ctrl_l(); sleep 0.5
109
+ enter(url); sleep 4
84
110
 
85
111
  end
86
112
 
@@ -94,10 +120,20 @@ class XAutoBrowse
94
120
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
95
121
  end
96
122
 
123
+ def carriage_return()
124
+ XDo::Keyboard.return
125
+ end
126
+
127
+ alias cr carriage_return
128
+
129
+ def tab(n=1)
130
+ XDo::Keyboard.simulate("{TAB}" * n)
131
+ end
132
+
97
133
  def text_field(klass: nil, id: nil, name: nil, value: '')
98
134
 
99
135
  console = @browser == :firefox ? :ctrl_shift_k : :ctrl_shift_i
100
- XDo::Keyboard.send console # web console
136
+ method(console).call # web console
101
137
 
102
138
  sleep 3
103
139
 
@@ -109,37 +145,33 @@ class XAutoBrowse
109
145
 
110
146
  [cmd, "r.value = \"\"", "r.focus()"].each {|x| enter x}
111
147
 
112
- XDo::Keyboard.ctrl_shift_i # toggle tools
113
- sleep 2
114
- XDo::Keyboard.type(value)
148
+ ctrl_shift_i() # toggle tools
115
149
  sleep 2
150
+ type(value); sleep 1
116
151
 
117
152
  end
118
153
 
119
154
  def to_doc()
120
- copy_source()
121
- sleep 0.5
155
+ copy_source(); sleep 0.5
122
156
  Nokorexi.new(Clipboard.paste).to_doc
123
157
  end
124
158
 
159
+ def type(s)
160
+ XDo::Keyboard.type(s)
161
+ end
162
+
125
163
  def view_source()
126
164
 
127
- @wm.action_window(@id, :activate)
128
- sleep 0.5
129
- XDo::Keyboard.ctrl_l # jump to the location bar
165
+ activate(); sleep 0.5
166
+ ctrl_l() # jump to the location bar
130
167
  sleep 0.6
131
- XDo::Keyboard.simulate("{TAB}" * 2)
132
- sleep 0.5
133
- XDo::Keyboard.ctrl_u # View source code
134
- end
135
-
136
- private
168
+ tab(2); sleep 0.5
169
+ ctrl_u() # View source code
170
+
171
+ end
137
172
 
138
- def enter(s)
139
- XDo::Keyboard.type(s)
140
- sleep 0.8
141
- XDo::Keyboard.return
142
- sleep 1
143
- end
173
+ # input some text
174
+ #
175
+ def enter(s) type(s); sleep 0.8; carriage_return(); sleep 1 end
144
176
 
145
177
  end
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file