webdrone 0.4.0 → 0.5.0

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: cb888344d4b82d0c3747d3812b275d13313accc0
4
- data.tar.gz: 1b373f581493ed391fc44e82fa1040909ac037cc
3
+ metadata.gz: e01d81e7399969fed94be37f103881f1d37cba83
4
+ data.tar.gz: 10b7013b03c6cf91b851f55f458c46596b95078d
5
5
  SHA512:
6
- metadata.gz: 545229f0fa9da4eff8a7e477810e37bb10112a1684cccde6c210e861ea9e1d0ec43c31eecbf17d7e886ec7094ed0ea0ba0890b6d60cf6c0d104082623b4e88d1
7
- data.tar.gz: 384975fb4517f9a7bf2923798e94db24c0a3686d92d77cfa0110777ddfe89b05f8e481adc2556ba713a6199809791006c316005d30781f43392d5111db3db5f7
6
+ metadata.gz: 0dabeac3953e01aadb05aecd18016c6b8db6fda87a737c55111e6df1e28be69b6e202a91d0a2378396dbbf36da3988bb308894764ffc4737c887d7552c92c0c7
7
+ data.tar.gz: 303f2ba7d839eec7c4528fd32b7dd4fd611b80aad5579caec03fb8e9183d03e3e62c3a9ae82fde5502031047a3e5330d610d38901f110eba16af74ebc59d3356
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ webdrone_output_*
11
+ screenshot-*.png
@@ -4,7 +4,7 @@ module Webdrone
4
4
 
5
5
  def initialize(browser: 'chrome', create_outdir: false, outdir: nil)
6
6
  if create_outdir or outdir
7
- outdir ||= "webdrone_output_#{Time.new.strftime('%Y%m%d_%H%M')}"
7
+ outdir ||= "webdrone_output/#{Time.new.strftime('%Y%m%d_%H%M')}"
8
8
  self.conf.outdir = outdir
9
9
  end
10
10
  if outdir != nil and browser.to_sym == :chrome
data/lib/webdrone/clic.rb CHANGED
@@ -16,6 +16,10 @@ module Webdrone
16
16
  @a0.find.id(text).click
17
17
  end
18
18
 
19
+ def css(text)
20
+ @a0.find.css(text).click
21
+ end
22
+
19
23
  def link(text, n: 1, all: false, visible: true)
20
24
  @a0.find.link(text, n: n, all: all, visible: visible).click
21
25
  end
data/lib/webdrone/ctxt.rb CHANGED
@@ -10,6 +10,7 @@ module Webdrone
10
10
 
11
11
  def initialize(a0)
12
12
  @a0 = a0
13
+ @framestack = []
13
14
  end
14
15
 
15
16
  def create_tab
@@ -23,15 +24,15 @@ module Webdrone
23
24
  end
24
25
 
25
26
  def with_frame(name)
26
- old_frame = @current_frame
27
+ @framestack << name
27
28
  @a0.driver.switch_to.frame name
28
- @current_frame = name
29
29
  if block_given?
30
30
  yield
31
- @a0.driver.switch_to.frame old_frame
32
- @current_frame = old_frame
31
+ @framestack.pop
32
+ @a0.driver.switch_to.default_content
33
+ @framestack.each { |frame| @a0.driver.switch_to.frame frame}
33
34
  end
34
- @current_frame
35
+ name
35
36
  end
36
37
 
37
38
  def with_alert
data/lib/webdrone/find.rb CHANGED
@@ -18,6 +18,13 @@ module Webdrone
18
18
  end
19
19
  end
20
20
 
21
+ def css(text, n: 1, all: false, visible: true)
22
+ @a0.wait.for do
23
+ items = @a0.driver.find_elements :css, text
24
+ choose(items, n, all, visible)
25
+ end
26
+ end
27
+
21
28
  def link(text, n: 1, all: false, visible: true)
22
29
  self.xpath XPath::HTML.link(text).to_s, n: n, all: all, visible: visible
23
30
  end
data/lib/webdrone/mark.rb CHANGED
@@ -16,6 +16,10 @@ module Webdrone
16
16
  flash @a0.find.id(text), color: color
17
17
  end
18
18
 
19
+ def css(text, color: 'red', n: 1, all: false, visible: true)
20
+ flash @a0.find.css(text, n: n, all: all, visible: visible), color: color
21
+ end
22
+
19
23
  def link(text, color: 'red', n: 1, all: false, visible: true)
20
24
  flash @a0.find.link(text, n: n, all: all, visible: visible), color: color
21
25
  end
data/lib/webdrone/text.rb CHANGED
@@ -16,6 +16,10 @@ module Webdrone
16
16
  @a0.find.id(text).text
17
17
  end
18
18
 
19
+ def css(text)
20
+ @a0.find.css(text).text
21
+ end
22
+
19
23
  def link(text, n: 1, all: false, visible: true)
20
24
  @a0.find.link(text, n: n, all: all, visible: visible).text
21
25
  end
@@ -1,3 +1,3 @@
1
1
  module Webdrone
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/webdrone/vrfy.rb CHANGED
@@ -16,6 +16,10 @@ module Webdrone
16
16
  vrfy @a0.find.id(text), attr: attr, eq: eq, contains: contains
17
17
  end
18
18
 
19
+ def css(text, attr: nil, eq: nil, contains: nil)
20
+ vrfy @a0.find.css(text), attr: attr, eq: eq, contains: contains
21
+ end
22
+
19
23
  def link(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil)
20
24
  vrfy @a0.find.link(text, n: n, visible: visible), attr: attr, eq: eq, contains: contains
21
25
  end
@@ -35,7 +39,7 @@ module Webdrone
35
39
  def xpath(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil)
36
40
  vrfy @a0.find.xpath(text, n: n, visible: visible), attr: attr, eq: eq, contains: contains
37
41
  end
38
-
42
+
39
43
  def vrfy(item, attr: nil, eq: nil, contains: nil)
40
44
  if attr != nil
41
45
  r = item.attribute(attr) == eq if eq != nil
data/lib/webdrone/xlsx.rb CHANGED
@@ -6,7 +6,7 @@ module Webdrone
6
6
  end
7
7
 
8
8
  class Xlsx
9
- attr_accessor :a0, :filename, :sheet, :dict, :rows
9
+ attr_accessor :a0, :filename, :sheet, :dict, :rows, :both
10
10
 
11
11
  def initialize(a0)
12
12
  @a0 = a0
@@ -17,6 +17,7 @@ module Webdrone
17
17
  def dict(sheet: nil, filename: nil)
18
18
  update_sheet_filename(sheet, filename)
19
19
  if @dict == nil
20
+ reset
20
21
  @dict = {}
21
22
  workbook = RubyXL::Parser.parse(@filename)
22
23
  worksheet = workbook[@sheet]
@@ -30,9 +31,10 @@ module Webdrone
30
31
  @dict
31
32
  end
32
33
 
33
- def rows(sheet: nil, filename: nil, dict: false)
34
+ def rows(sheet: nil, filename: nil)
34
35
  update_sheet_filename(sheet, filename)
35
36
  if @rows == nil
37
+ reset
36
38
  workbook = RubyXL::Parser.parse(@filename)
37
39
  worksheet = workbook[@sheet]
38
40
  @rows = worksheet.sheet_data.rows.collect do |row|
@@ -41,9 +43,22 @@ module Webdrone
41
43
  end
42
44
  end
43
45
  end
44
- if dict
45
- head = @rows.shift
46
- @rows = @rows.collect do |row|
46
+ @rows
47
+ end
48
+
49
+ def both(sheet: nil, filename: nil)
50
+ update_sheet_filename(sheet, filename)
51
+ if @both == nil
52
+ reset
53
+ workbook = RubyXL::Parser.parse(@filename)
54
+ worksheet = workbook[@sheet]
55
+ rows = worksheet.sheet_data.rows.collect do |row|
56
+ row.cells.collect do |cell|
57
+ cell.value if cell != nil
58
+ end
59
+ end
60
+ head = rows.shift
61
+ @both = rows.collect do |row|
47
62
  dict = {}
48
63
  row.each_with_index do |val, i|
49
64
  dict[head[i]] = val if head[i] != nil
@@ -51,23 +66,26 @@ module Webdrone
51
66
  dict
52
67
  end
53
68
  end
54
- @rows
69
+ @both
55
70
  end
56
71
 
72
+
57
73
  def save(sheet: nil, filename: nil, dict: nil, rows: nil)
58
74
  @filename = filename if filename
59
75
  @sheet = sheet if sheet
60
76
  workbook = RubyXL::Parser.parse(@filename)
61
77
  worksheet = workbook[@sheet]
62
- if dict != nil
78
+ if @dict != nil
63
79
  worksheet.sheet_data.rows.tap do |head, *body|
64
80
  body.each do |row|
65
81
  k = row[0].value
66
- row[1].change_contents(dict[k]) if dict.include?(k)
82
+ if @dict.include?(k)
83
+ row[1].change_contents(@dict[k])
84
+ end
67
85
  end
68
86
  end
69
- elsif rows != nil
70
- rows.each_with_index do |row, rowi|
87
+ elsif @rows != nil
88
+ @rows.each_with_index do |row, rowi|
71
89
  row.each_with_index do |data, coli|
72
90
  if worksheet[rowi] == nil || worksheet[rowi][coli] == nil
73
91
  worksheet.add_cell(rowi, coli, data)
@@ -76,20 +94,37 @@ module Webdrone
76
94
  end
77
95
  end
78
96
  end
97
+ elsif @both != nil
98
+ rows = worksheet.sheet_data.rows.collect do |row|
99
+ row.cells.collect do |cell|
100
+ cell.value if cell != nil
101
+ end
102
+ end
103
+ head = rows.shift
104
+ @both.each_with_index do |entry, i|
105
+ entry.each do |k, v|
106
+ index = head.index(k)
107
+ worksheet[i + 1][index].change_contents(v) if index
108
+ end
109
+ end
79
110
  end
80
- workbook.write(filename)
81
- @dict = @rows = nil
111
+ k = workbook.write(@filename)
112
+ reset
113
+ end
114
+
115
+ def reset()
116
+ @dict = @rows = @both = nil
82
117
  end
83
118
 
84
119
  protected
85
120
  def update_sheet_filename(sheet, filename)
86
121
  if sheet and sheet != @sheet
87
122
  @sheet = sheet
88
- @dict = @rows = nil
123
+ reset
89
124
  end
90
125
  if filename and filename != @filename
91
126
  @filename = filename
92
- @dict = @rows = nil
127
+ reset
93
128
  end
94
129
  end
95
130
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webdrone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldrin Martoq
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2015-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler