gridium 1.0.25 → 1.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/element.rb +20 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c4000b1d9492350bd2822865345f7ea075f4a21
4
- data.tar.gz: b0fe0e9605f43905fd72d3eebec8fa8e35e543fb
3
+ metadata.gz: 4c1e455704eb16cbaa41dc2b5c57292be5df9366
4
+ data.tar.gz: 9dd5f0f17283d420d28b33daee281e2bbafe6ae5
5
5
  SHA512:
6
- metadata.gz: c4b2a1943330d58b59e3e303da9e1230922fc672a807c727d4931eef9b94381c59bbae8f14836bede3fd2be6b78caa023be79b3c3842edd7021da0c1fcdc8a53
7
- data.tar.gz: 783500fba46309e94a3c708856626880d683a275a3fd21fc035d3c59dc15e5dea106b83287a73319e793208bded616ecf4fc006767fe41dcff3741e12180bebe
6
+ metadata.gz: ee7d951178c72bfabb80e29a54e3b9d365619554e1c39c36766de08124ed0e51e06f70e58e1a255ad139861e368782fbe8610b55bb7bac3faa33531630a6f63f
7
+ data.tar.gz: 47b30b89aceca4377ea1d25b80458315aae5c1e349d2380087247c781c330f650c7eefeb49049615b81d9029f73aa77109ce2d2db78fd0e47cb83b8c2f5cb295
data/lib/element.rb CHANGED
@@ -6,7 +6,7 @@ class Element
6
6
  attr_reader :name, :by, :locator
7
7
 
8
8
 
9
- def initialize(name, by, locator)
9
+ def initialize(name, by, locator, opts = {})
10
10
  @name = name
11
11
  @by = by
12
12
  @locator = locator
@@ -18,6 +18,9 @@ class Element
18
18
  # selenium web element
19
19
  @element = nil
20
20
 
21
+ # should always be driver unless getting an element's child
22
+ @parent ||= (opts[:parent] || @driver)
23
+
21
24
  #how long to wait between clearing an input and sending keys to it
22
25
  @text_padding_time = 0.15
23
26
  end
@@ -32,7 +35,7 @@ class Element
32
35
  if Gridium.config.visible_elements_only
33
36
  wait.until { @element = displayed_element }
34
37
  else
35
- wait.until { @element = @driver.find_element(@by, @locator); Log.debug("Finding element #{self}..."); @element.enabled? }
38
+ wait.until { @element = @parent.find_element(@by, @locator); Log.debug("Finding element #{self}..."); @element.enabled? }
36
39
  end
37
40
 
38
41
  end
@@ -47,7 +50,7 @@ class Element
47
50
  found_element = nil
48
51
  #Found an issue where the element would go stale after it's found
49
52
  begin
50
- elements = @driver.find_elements(@by, @locator)
53
+ elements = @parent.find_elements(@by, @locator)
51
54
  elements.each do |element|
52
55
  if element.displayed? #removed check for element.enabled
53
56
  found_element = element; #this will always return the last displayed element
@@ -90,6 +93,12 @@ class Element
90
93
  element.attribute(name)
91
94
  end
92
95
 
96
+ def css_value(name)
97
+ element.css_value(name)
98
+ end
99
+
100
+
101
+
93
102
  def present?
94
103
  return element.enabled?
95
104
  rescue StandardError => error
@@ -166,10 +175,15 @@ class Element
166
175
 
167
176
 
168
177
 
178
+
169
179
  def location
170
180
  element.location
171
181
  end
172
182
 
183
+ def location_once_scrolled_into_view
184
+ element.location_once_scrolled_into_view
185
+ end
186
+
173
187
  def hover_over
174
188
  Log.debug("Hovering over element (#{self.to_s})...")
175
189
  # @driver.mouse.move_to(element) # Note: Doesn't work with Selenium 2.42 bindings for Firefox v31
@@ -254,7 +268,7 @@ class Element
254
268
  #
255
269
  def find_element(by, locator)
256
270
  Log.debug('Finding element...')
257
- element.find_element(by, locator)
271
+ Element.new("Child of #{@name}", by, locator, parent: @element)
258
272
  end
259
273
 
260
274
  #
@@ -266,7 +280,8 @@ class Element
266
280
  # @return [Array] elements
267
281
  #
268
282
  def find_elements(by, locator)
269
- element.find_elements(by, locator)
283
+ elements = element.find_elements(by, locator)
284
+ elements.map {|_| Element.new("Child of #{@name}", by, locator, parent: @element)}
270
285
  end
271
286
 
272
287
  def save_element_screenshot
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.25
4
+ version: 1.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Urban
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  version: '0'
188
188
  requirements: []
189
189
  rubyforge_project:
190
- rubygems_version: 2.6.10
190
+ rubygems_version: 2.6.11
191
191
  signing_key:
192
192
  specification_version: 4
193
193
  summary: This Gem is used to make building Selenium Tests without Capybara Easier.