xautobrowse 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -1
- data/lib/xautobrowse.rb +54 -43
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: b9dc540e0b04475206bfb66e573051863fa47d3a
|
4
|
+
data.tar.gz: 14de8bd5cece431bfe6c5bc7798000bef2a130ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bd24b0b07f7f04eecc4a92152c4c6dcbb91b4eccf54f30f0dea147b5a5f901f90fa2e0f9f631efb22091dba9e3f57d1128bf057dbd3a5d6814809cdc33b717e
|
7
|
+
data.tar.gz: f79d47b395c4682ef179a2f31fd9fb1dae0d50782a0c48863f8dd36102cfedf20b96599150198c28d49f9b3015cb45cc0b4eff0fa57ad37fe066e50eda75e7ad
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
!Y���V���d�����u3�����]0��HS>$�YG�1�$�N���"�Wx���2�aj�mw����j�=� �n
|
data/lib/xautobrowse.rb
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
|
9
9
|
# revision log:
|
10
10
|
|
11
|
+
# 1 Feb 2018: feature: Implemented XAutoBrowse#screenshot
|
11
12
|
# 31 Jan 2018: feature: Implemented XAutoBrowse#click which accepts a key of
|
12
13
|
# an element to be clicked e.g. click :logout
|
13
14
|
# 30 Jan 2018: feature: Now uses the gem universal_dom_remote to
|
@@ -104,13 +105,12 @@ class XAutoBrowse
|
|
104
105
|
|
105
106
|
def initialize(browser= :firefox, debug: false, sps: false, clicks: {})
|
106
107
|
|
107
|
-
@browser, @debug, @clicks = browser, debug, clicks
|
108
|
+
@browser, @debug, @sps, @clicks = browser, debug, sps, clicks
|
108
109
|
|
109
|
-
@window = Window.new
|
110
|
-
sleep
|
111
|
-
|
110
|
+
@window = Window.new(browser); sleep 2
|
111
|
+
#Thread.new { web_console() { sleep 1 } }
|
112
|
+
sleep 2
|
112
113
|
|
113
|
-
@sps = sps
|
114
114
|
connect() if sps
|
115
115
|
|
116
116
|
end
|
@@ -132,8 +132,7 @@ class XAutoBrowse
|
|
132
132
|
|
133
133
|
clipboard = Clipboard.paste
|
134
134
|
Clipboard.copy javascript(); sleep 1
|
135
|
-
ctrl_v(); sleep 0.5
|
136
|
-
carriage_return()
|
135
|
+
ctrl_v(); sleep 0.5; carriage_return()
|
137
136
|
|
138
137
|
close_web_console() if autohide
|
139
138
|
Clipboard.copy clipboard
|
@@ -142,7 +141,7 @@ class XAutoBrowse
|
|
142
141
|
|
143
142
|
def click(name)
|
144
143
|
|
145
|
-
|
144
|
+
web_console {|x| x.enter @clicks[name] + '.click();' }
|
146
145
|
|
147
146
|
end
|
148
147
|
|
@@ -150,6 +149,8 @@ class XAutoBrowse
|
|
150
149
|
ctrl_w()
|
151
150
|
end
|
152
151
|
|
152
|
+
alias exit close
|
153
|
+
|
153
154
|
def close_web_console()
|
154
155
|
@window.activate()
|
155
156
|
ctrl_shift_i()
|
@@ -159,9 +160,8 @@ class XAutoBrowse
|
|
159
160
|
|
160
161
|
def connect()
|
161
162
|
|
162
|
-
start_broker()
|
163
|
-
|
164
|
-
connect_controller()
|
163
|
+
start_broker(); sleep 4; connect_controller()
|
164
|
+
|
165
165
|
end
|
166
166
|
|
167
167
|
# Connects to the SPS broker to communicate with the web browser
|
@@ -173,8 +173,7 @@ class XAutoBrowse
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def copy_screen()
|
176
|
-
select_all(); sleep 2; ctrl_c(); sleep 2
|
177
|
-
unselect_all()
|
176
|
+
select_all(); sleep 2; ctrl_c(); sleep 2; unselect_all()
|
178
177
|
Clipboard.paste
|
179
178
|
end
|
180
179
|
|
@@ -183,8 +182,7 @@ class XAutoBrowse
|
|
183
182
|
def copy_source()
|
184
183
|
|
185
184
|
view_source(); sleep 3
|
186
|
-
select_all()
|
187
|
-
sleep 1
|
185
|
+
select_all(); sleep 1
|
188
186
|
ctrl_c() # copy the source code to the clipboard
|
189
187
|
sleep 1
|
190
188
|
ctrl_w() # close the viewsource window
|
@@ -235,9 +233,7 @@ class XAutoBrowse
|
|
235
233
|
|
236
234
|
if block_given? then
|
237
235
|
|
238
|
-
@window.activate(); sleep
|
239
|
-
yield(self)
|
240
|
-
carriage_return()
|
236
|
+
@window.activate(); sleep 1; yield(self); carriage_return()
|
241
237
|
|
242
238
|
end
|
243
239
|
|
@@ -245,16 +241,14 @@ class XAutoBrowse
|
|
245
241
|
|
246
242
|
def goto(url, attachconsole: true)
|
247
243
|
|
248
|
-
|
249
|
-
|
250
|
-
enter(url); sleep 7
|
244
|
+
sleep 1; ctrl_l(); sleep 2
|
245
|
+
enter(url); sleep 5
|
251
246
|
attach_console() if @sps and attachconsole
|
252
247
|
|
253
248
|
end
|
254
249
|
|
255
250
|
def carriage_return()
|
256
|
-
@window.activate(); sleep 1
|
257
|
-
XDo::Keyboard.return
|
251
|
+
@window.activate(); sleep 1; XDo::Keyboard.return
|
258
252
|
end
|
259
253
|
|
260
254
|
alias cr carriage_return
|
@@ -273,6 +267,28 @@ class XAutoBrowse
|
|
273
267
|
|
274
268
|
end
|
275
269
|
|
270
|
+
alias web_console open_web_console
|
271
|
+
|
272
|
+
# Takes a screenshot of the web page. Images are stored in ~/Pictures
|
273
|
+
#
|
274
|
+
def screenshot(filename=Time.now\
|
275
|
+
.strftime("Screenshot from %Y-%m-%d %d-%m-%y"))
|
276
|
+
|
277
|
+
XDo::Keyboard.simulate('{print}');
|
278
|
+
sleep 4;
|
279
|
+
XDo::Keyboard.simulate("{down}")
|
280
|
+
sleep 4;
|
281
|
+
XDo::Keyboard.alt_s
|
282
|
+
sleep 5;
|
283
|
+
XDo::Keyboard.type filename
|
284
|
+
sleep 3
|
285
|
+
XDo::Keyboard.alt_s
|
286
|
+
sleep 1
|
287
|
+
|
288
|
+
end
|
289
|
+
|
290
|
+
alias screen_capture screenshot
|
291
|
+
|
276
292
|
def send(s)
|
277
293
|
@udr.send s
|
278
294
|
end
|
@@ -283,11 +299,7 @@ class XAutoBrowse
|
|
283
299
|
|
284
300
|
def unselect_all()
|
285
301
|
|
286
|
-
|
287
|
-
tab(); shift_tab()
|
288
|
-
else
|
289
|
-
ctrl_shift_a()
|
290
|
-
end
|
302
|
+
@browser == :firefox ? (tab(); shift_tab()) : ctrl_shift_a()
|
291
303
|
|
292
304
|
end
|
293
305
|
|
@@ -315,25 +327,26 @@ class XAutoBrowse
|
|
315
327
|
end
|
316
328
|
|
317
329
|
def tab(n=1)
|
318
|
-
@window.activate()
|
319
|
-
XDo::Keyboard.simulate("{TAB}" * n)
|
330
|
+
@window.activate(); XDo::Keyboard.simulate("{TAB}" * n)
|
320
331
|
end
|
321
332
|
|
322
333
|
def text_field(klass: nil, id: nil, name: nil, value: '')
|
323
334
|
|
324
|
-
open_web_console()
|
335
|
+
open_web_console() do |console|
|
325
336
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
337
|
+
cmd = if klass then
|
338
|
+
"querySelector('#{klass}')"
|
339
|
+
elsif id then
|
340
|
+
"getElementById(\"#{id}\")"
|
341
|
+
end
|
331
342
|
|
332
|
-
|
343
|
+
['r = document.' + cmd, "r.value = \"\"", "r.focus()"].each do |x|
|
344
|
+
console.enter x
|
345
|
+
end
|
333
346
|
|
334
|
-
|
335
|
-
|
336
|
-
type(value); sleep 1
|
347
|
+
end
|
348
|
+
|
349
|
+
sleep 2; type(value); sleep 1
|
337
350
|
|
338
351
|
end
|
339
352
|
|
@@ -350,9 +363,7 @@ class XAutoBrowse
|
|
350
363
|
|
351
364
|
@window.activate(); sleep 0.5
|
352
365
|
ctrl_l() # jump to the location bar
|
353
|
-
sleep 0.6
|
354
|
-
tab(2); sleep 0.5
|
355
|
-
ctrl_u() # View source code
|
366
|
+
sleep 0.6; tab(2); sleep 0.5; ctrl_u() # View source code
|
356
367
|
|
357
368
|
end
|
358
369
|
|
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
UkT65Cjj3pGfXSA+uRiXo7EXRM2Xft7NA1wuE91g2PYjRb8GvdqjxrgF1gp+LHtf
|
31
31
|
Gwk=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-01
|
33
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: xdo
|
metadata.gz.sig
CHANGED
Binary file
|