testcentricity_web 0.8.2 → 0.8.3
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
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7a8bd1506e8dca866cb4eb471864452a4553c14
|
4
|
+
data.tar.gz: 8d82ed2f8313b4469f2fe5ed718e70e7fb3a2389
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a11e9d5127c6e7b7696fe9848d82ea9e567b08e9fe0ecc310bfa9d64106a6217d006983c1eb07e3ef794719218066427313f52d9ac09f67bcde06e4346a78d1
|
7
|
+
data.tar.gz: 513cbce517d55774862934a9e7d16eff505bfa03a78805d335a80935113a14ca05cb4b134f5fdb25f3b1f110b9f3f02d6c40ebd4f40c852384fa02cf682770ba
|
@@ -1,11 +1,46 @@
|
|
1
1
|
module TestCentricity
|
2
2
|
class Table < UIElement
|
3
|
+
attr_accessor :table_body
|
4
|
+
attr_accessor :table_row
|
5
|
+
attr_accessor :table_column
|
6
|
+
attr_accessor :table_header
|
7
|
+
attr_accessor :header_row
|
8
|
+
attr_accessor :header_column
|
9
|
+
|
3
10
|
def initialize(parent, locator, context)
|
4
|
-
@parent
|
5
|
-
@locator
|
6
|
-
@context
|
7
|
-
@type
|
8
|
-
@alt_locator
|
11
|
+
@parent = parent
|
12
|
+
@locator = locator
|
13
|
+
@context = context
|
14
|
+
@type = :table
|
15
|
+
@alt_locator = nil
|
16
|
+
|
17
|
+
table_spec = { :table_body => 'tbody',
|
18
|
+
:table_row => 'tr',
|
19
|
+
:table_column => 'td',
|
20
|
+
:table_header => 'thead',
|
21
|
+
:header_row => 'tr',
|
22
|
+
:header_column => 'th'
|
23
|
+
}
|
24
|
+
define_table_elements(table_spec)
|
25
|
+
end
|
26
|
+
|
27
|
+
def define_table_elements(element_spec)
|
28
|
+
element_spec.each do | element, value |
|
29
|
+
case element
|
30
|
+
when :table_body
|
31
|
+
@table_body = value
|
32
|
+
when :table_row
|
33
|
+
@table_row = value
|
34
|
+
when :table_column
|
35
|
+
@table_column = value
|
36
|
+
when :table_header
|
37
|
+
@table_header = value
|
38
|
+
when :header_row
|
39
|
+
@header_row = value
|
40
|
+
when :header_column
|
41
|
+
@header_column = value
|
42
|
+
end
|
43
|
+
end
|
9
44
|
end
|
10
45
|
|
11
46
|
# Return number of rows in a table object.
|
@@ -16,7 +51,7 @@ module TestCentricity
|
|
16
51
|
#
|
17
52
|
def get_row_count
|
18
53
|
wait_until_exists(5)
|
19
|
-
row_count = page.all(:xpath, "#{@locator}
|
54
|
+
row_count = page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}", :visible => :all).count
|
20
55
|
row_count
|
21
56
|
end
|
22
57
|
|
@@ -29,11 +64,11 @@ module TestCentricity
|
|
29
64
|
def get_column_count
|
30
65
|
row_count = get_row_count
|
31
66
|
if row_count == 0
|
32
|
-
page.all(:xpath, "#{@locator}
|
67
|
+
page.all(:xpath, "#{@locator}/#{@table_header}/#{@header_row}/#{@header_column}", :visible => :all).count
|
33
68
|
else
|
34
69
|
(row_count == 1) ?
|
35
|
-
page.all(:xpath, "#{@locator}
|
36
|
-
page.all(:xpath, "#{@locator}
|
70
|
+
page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}/#{@table_column}", :visible => :all).count :
|
71
|
+
page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}[2]/#{@table_column}", :visible => :all).count
|
37
72
|
end
|
38
73
|
end
|
39
74
|
|
@@ -128,8 +163,8 @@ module TestCentricity
|
|
128
163
|
row_count = get_row_count
|
129
164
|
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count
|
130
165
|
(row > 1) ?
|
131
|
-
set_alt_locator("#{@locator}
|
132
|
-
set_alt_locator("#{@locator}
|
166
|
+
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}[#{row}]") :
|
167
|
+
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}")
|
133
168
|
value = get_value if exists?
|
134
169
|
clear_alt_locator
|
135
170
|
value
|
@@ -255,7 +290,7 @@ module TestCentricity
|
|
255
290
|
def click_header_column(column)
|
256
291
|
column_count = get_column_count
|
257
292
|
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count
|
258
|
-
set_alt_locator("#{@locator}
|
293
|
+
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
259
294
|
click if exists?
|
260
295
|
clear_alt_locator
|
261
296
|
end
|
@@ -263,7 +298,7 @@ module TestCentricity
|
|
263
298
|
def get_header_column(column)
|
264
299
|
column_count = get_column_count
|
265
300
|
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count
|
266
|
-
set_alt_locator("#{@locator}
|
301
|
+
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
267
302
|
value = get_value(:all) if exists?(:all)
|
268
303
|
clear_alt_locator
|
269
304
|
value
|
@@ -273,14 +308,13 @@ module TestCentricity
|
|
273
308
|
columns = []
|
274
309
|
column_count = get_column_count
|
275
310
|
(1..column_count).each do |column|
|
276
|
-
set_alt_locator("#{@locator}
|
311
|
+
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
277
312
|
columns.push(get_value(:all)) if exists?(:all)
|
278
313
|
end
|
279
314
|
clear_alt_locator
|
280
315
|
columns
|
281
316
|
end
|
282
317
|
|
283
|
-
|
284
318
|
def is_table_row_expanded?(row, column)
|
285
319
|
row_count = get_row_count
|
286
320
|
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count
|
@@ -324,9 +358,9 @@ module TestCentricity
|
|
324
358
|
private
|
325
359
|
|
326
360
|
def set_table_cell_locator(row, column)
|
327
|
-
row_spec = "#{@locator}
|
361
|
+
row_spec = "#{@locator}/#{@table_body}/#{@table_row}"
|
328
362
|
row_spec = "#{row_spec}[#{row}]" if row > 1
|
329
|
-
column_spec = "
|
363
|
+
column_spec = "/#{@table_column}[#{column}]"
|
330
364
|
set_alt_locator("#{row_spec}#{column_spec}")
|
331
365
|
end
|
332
366
|
|
@@ -197,6 +197,20 @@ module TestCentricity
|
|
197
197
|
raise "Could not find element #{@locator} after #{timeout} seconds" unless exists?
|
198
198
|
end
|
199
199
|
|
200
|
+
# Wait until the object is visible, or until the specified wait time has expired.
|
201
|
+
#
|
202
|
+
# @param seconds [Integer or Float] wait time in seconds
|
203
|
+
# @example
|
204
|
+
# run_button.wait_until_visible(0.5)
|
205
|
+
#
|
206
|
+
def wait_until_visible(seconds = nil)
|
207
|
+
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
208
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
209
|
+
wait.until { visible? }
|
210
|
+
rescue
|
211
|
+
raise "Could not find element #{@locator} after #{timeout} seconds" unless exists?
|
212
|
+
end
|
213
|
+
|
200
214
|
# Wait until the object no longer exists, or until the specified wait time has expired.
|
201
215
|
#
|
202
216
|
# @param seconds [Integer or Float] wait time in seconds
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testcentricity_web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A.J. Mrozinski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|