xautobrowse 0.2.6 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: be7edcbc3108b110f0785f5402c5d2030375d260
4
- data.tar.gz: 545779ec6e9792413c45a6d7d2cf46c2a96b42dd
2
+ SHA256:
3
+ metadata.gz: e71119d67c1f7a76df4466079409be87b0980aeb6473324696bd872e9b59f37e
4
+ data.tar.gz: 147b61fc5cfc2957542998d6b9e6ac4a8656f831791ad363ce3b9d2bb9c9d87d
5
5
  SHA512:
6
- metadata.gz: 0ecb265dfbefd02ab544756ac16334ff15871663dec0f262f1054fe6e68850556899487000f3d07acacc17df26786714c706cbf74b7ef6f8df6c575f1a901516
7
- data.tar.gz: 38b75cccfa5c3f2414fcc8fcfc98f56fc4afe348b1caf66ed3f0f59771308008a51bfe7b882be3889e23b5b5b64c69b4024dca226ee6ed577b42aaea74970602
6
+ metadata.gz: fcd0cc0b066699e3f239d79a990ffab514808327d29c176370ebfce542ea19814b72050691356cdb9fe503e3643f13cfa171a394fa0e132d86333df9c7315ce8
7
+ data.tar.gz: 573e981566daa1390c90f082dc16f00b022bc24add6f2ab26cb39431431e76b188cc5466c279453b5bd8c4bd1edaea9347d7241f536596d014d017bd4944d207
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/xautobrowse.rb CHANGED
@@ -9,6 +9,7 @@
9
9
 
10
10
  # revision log:
11
11
 
12
+ # 4 Sep 2018: feature: Tabs can now be traversed using the XTabbedWindow gem
12
13
  # 23 Jun 2018: feature: A new Window can now be created which attaches itself
13
14
  # to the most recent application window created
14
15
  # 12 Feb 2018: bug fix: Implemented the missing method ctrl_shift_k() used
@@ -32,12 +33,12 @@
32
33
  # Then paste the code to a new notepad document for inspection.
33
34
 
34
35
 
35
- require 'wmctrl'
36
+ #require 'wmctrl'
36
37
  require 'nokorexi'
37
38
  require 'clipboard'
38
- require 'xdo/mouse'
39
- require 'xdo/keyboard'
40
- require 'xdo/xwindow'
39
+ #require 'xdo/mouse'
40
+ #require 'xdo/keyboard'
41
+ #require 'xdo/xwindow'
41
42
  require 'sps-pub'
42
43
  require 'universal_dom_remote'
43
44
 
@@ -55,26 +56,32 @@ class XAutoBrowse
55
56
 
56
57
  end
57
58
 
58
- class Window
59
+ class Window < XTabbedWindow
59
60
 
60
- def initialize(browser=nil)
61
+ def initialize(browser=nil, new_win: true)
61
62
 
62
63
  @wm = WMCtrl.instance
63
64
 
64
65
  if browser then
65
- spawn(browser.to_s); sleep 3
66
66
 
67
- id = XDo::XWindow.wait_for_window(browser.to_s)
68
-
69
- xwin = XDo::XWindow.new(id)
70
- title = xwin.title
71
- puts 'title: ' + title.inspect if @debug
72
-
73
- # WMCtrl is used because XDo is problematic at trying to activate a window
74
-
75
- a = @wm.list_windows true
76
- puts 'a: ' + a.inspect if @debug
77
- r = a.reverse.find {|x| x[:title] =~ /#{browser}$/i}
67
+ if new_win then
68
+ spawn(browser.to_s); sleep 3
69
+
70
+ id = XDo::XWindow.wait_for_window(browser.to_s)
71
+
72
+ xwin = XDo::XWindow.new(id)
73
+ title = xwin.title
74
+ puts 'title: ' + title.inspect if @debug
75
+
76
+ # WMCtrl is used because XDo is problematic at trying to activate a window
77
+
78
+ a = @wm.list_windows true
79
+ puts 'a: ' + a.inspect if @debug
80
+ r = a.reverse.find {|x| x[:title] =~ /#{browser}$/i}
81
+ else
82
+ super(browser)
83
+ r = @window
84
+ end
78
85
  else
79
86
  a = @wm.list_windows true
80
87
  r = a.last
@@ -118,13 +125,15 @@ class XAutoBrowse
118
125
  attr_accessor :actions
119
126
 
120
127
 
121
- def initialize(browser= :firefox, debug: false, sps: false, clicks: {})
128
+ def initialize(browser= :firefox, new_window: true, debug: false,
129
+ sps: false, clicks: {})
122
130
 
123
131
  @browser, @debug, @sps, @clicks = browser.to_sym, debug, sps, clicks
132
+ @new_window = new_window
124
133
 
125
- @window = Window.new(browser); sleep 2
126
- #Thread.new { web_console() { sleep 1 } }
127
- sleep 2
134
+ @window = Window.new(browser, new_win: new_window)
135
+
136
+ sleep 4 if new_window
128
137
 
129
138
  connect() if sps
130
139
 
@@ -258,13 +267,20 @@ class XAutoBrowse
258
267
 
259
268
  end
260
269
 
261
- def goto(url, attachconsole: true)
270
+ def goto(url, attachconsole: true, new_tab: !@new_window)
262
271
 
263
- sleep 1; ctrl_l(); sleep 2
264
- enter(url); sleep 5
272
+ new_tab() if new_tab
273
+ sleep 1; ctrl_l()
274
+ sleep 2 if @new_window
275
+ enter(url)
276
+ sleep 5 if @new_window
265
277
  attach_console() if @sps and attachconsole
266
278
 
267
- end
279
+ end
280
+
281
+ def goto_tab(s)
282
+ @window.goto_tab(s)
283
+ end
268
284
 
269
285
  def carriage_return()
270
286
  @window.activate(); sleep 1; XDo::Keyboard.return
@@ -292,6 +308,10 @@ class XAutoBrowse
292
308
  @window = Window.new
293
309
  end
294
310
 
311
+ def new_tab()
312
+ @window.new_tab
313
+ end
314
+
295
315
  # Takes a screenshot of the web page. Images are stored in ~/Pictures
296
316
  #
297
317
  def screenshot(filename=Time.now\
@@ -353,6 +373,10 @@ class XAutoBrowse
353
373
  @window.activate(); XDo::Keyboard.simulate("{TAB}" * n)
354
374
  end
355
375
 
376
+ def tab?(s)
377
+ @window.tab?(s)
378
+ end
379
+
356
380
  def text_field(klass: nil, id: nil, name: nil, value: '')
357
381
 
358
382
  open_web_console() do |console|
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.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -30,48 +30,28 @@ cert_chain:
30
30
  UkT65Cjj3pGfXSA+uRiXo7EXRM2Xft7NA1wuE91g2PYjRb8GvdqjxrgF1gp+LHtf
31
31
  Gwk=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-06-23 00:00:00.000000000 Z
33
+ date: 2018-09-04 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
- name: xdo
36
+ name: xtabbedwindow
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0.0'
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: 0.0.4
45
- type: :runtime
46
- prerelease: false
47
- version_requirements: !ruby/object:Gem::Requirement
48
- requirements:
49
- - - "~>"
50
- - !ruby/object:Gem::Version
51
- version: '0.0'
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 0.0.4
55
- - !ruby/object:Gem::Dependency
56
- name: ruby-wmctrl
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.0'
41
+ version: '0.1'
62
42
  - - ">="
63
43
  - !ruby/object:Gem::Version
64
- version: 0.0.6
44
+ version: 0.1.1
65
45
  type: :runtime
66
46
  prerelease: false
67
47
  version_requirements: !ruby/object:Gem::Requirement
68
48
  requirements:
69
49
  - - "~>"
70
50
  - !ruby/object:Gem::Version
71
- version: '0.0'
51
+ version: '0.1'
72
52
  - - ">="
73
53
  - !ruby/object:Gem::Version
74
- version: 0.0.6
54
+ version: 0.1.1
75
55
  - !ruby/object:Gem::Dependency
76
56
  name: nokorexi
77
57
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
159
  version: '0'
180
160
  requirements: []
181
161
  rubyforge_project:
182
- rubygems_version: 2.6.13
162
+ rubygems_version: 2.7.6
183
163
  signing_key:
184
164
  specification_version: 4
185
165
  summary: A poor man's web automation tool primarily for Firefox in an X windows system.
metadata.gz.sig CHANGED
Binary file