gridium 1.1.35 → 1.1.36

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: bc44fb52f1320ccaf47d6d2ba4632e29b2f642e0
4
- data.tar.gz: ce69715beb35d69201f86c9266309afcf536ab42
3
+ metadata.gz: dc394adb83e2168340ced467ae4f27984776bc91
4
+ data.tar.gz: 131259a3fb64cbec4df0c59443199f27d15f7aad
5
5
  SHA512:
6
- metadata.gz: 6bf31c51af9cf634972368b93d4aceb9423f238b6102015651d2ec96252f69eb932680e99327070ee65ecc165c226cca53c1dfa24d63538b1e471503ffc5c91e
7
- data.tar.gz: 10c88c36c9c2a03a49604d0f4fc1d79a81e458bd21d798481b8c9d94167d6959e476e422411c7bf5d01f0efcc4209b912bbda6b9841b951a408adbb4645f187d
6
+ metadata.gz: d4bce2e0436804761bc3e6339da75fd0ea37177c4996ffe065cae100b1210d8ac2bed1eb3501256d4768e71bcb72c5e9927e29e258cffc1590f977d35847b572
7
+ data.tar.gz: 4dfc11fade041d3309a9ef17c846a380e54fd61b6b8537a775c9c63bf27835576917e44396b44a89497a82e93c91e2f3a3f9198251087e439dcfeda524749824
data/lib/element.rb CHANGED
@@ -94,14 +94,22 @@ class Element
94
94
  element.attribute(name)
95
95
  end
96
96
 
97
- # Requires element to have an ID value, to successfully use `document.getElementById`
97
+ # Requires element to have an unique css
98
+ # @param [String] name - attribute name
99
+ # @param [String] value - attribute value to set
98
100
  def set_attribute(name, value)
99
- id = self.attribute('id')
100
- if id.nil? || id.empty?
101
- Log.warn("[GRIDIUM::Element] #{self} does not have an 'id'. Consider adding one.")
101
+ Log.debug("[GRIDIUM::Element] setting element attribute '#{name}' to '#{value}'")
102
+
103
+ if self.by == :css
104
+ ElementExtensions.set_attribute(self.locator, name, value)
102
105
  else
103
- Log.debug("[GRIDIUM::Element] setting element attribute '#{name}' to '#{value}'")
104
- ElementExtensions.set_attribute(id, name, value)
106
+ # see if the element has an id to work with
107
+ id = self.attribute('id')
108
+ if id.nil? || id.empty?
109
+ Log.warn("[GRIDIUM::Element] #{self} does not have an 'id'. Consider adding one.")
110
+ else
111
+ ElementExtensions.set_attribute("[id=#{id}", name, value)
112
+ end
105
113
  end
106
114
  end
107
115
 
@@ -59,12 +59,12 @@ class Gridium::ElementExtensions
59
59
 
60
60
  #
61
61
  # Use Javascript to set element attribute value from :id
62
- # @param [String] id
63
- # @param [String] Attribute
64
- # @param [String] value
62
+ # @param [String] selector - css selector for find element by
63
+ # @param [String] attribute - element attribute to set
64
+ # @param [String] value - element value to set
65
65
  #
66
- def set_attribute(id, attr, val)
67
- Driver.execute_script_driver("document.getElementById('#{id}').setAttribute('#{attr}', '#{val}')");
66
+ def set_attribute(selector, attr, val)
67
+ Driver.execute_script_driver("document.querySelectorAll('#{selector}')[0].setAttribute('#{attr}', '#{val}')")
68
68
  end
69
69
  end
70
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.35
4
+ version: 1.1.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Urban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler