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 +4 -4
- data/lib/element.rb +14 -6
- data/lib/element_extensions.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc394adb83e2168340ced467ae4f27984776bc91
|
4
|
+
data.tar.gz: 131259a3fb64cbec4df0c59443199f27d15f7aad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
100
|
-
|
101
|
-
|
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
|
-
|
104
|
-
|
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
|
|
data/lib/element_extensions.rb
CHANGED
@@ -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]
|
63
|
-
# @param [String]
|
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(
|
67
|
-
Driver.execute_script_driver("document.
|
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.
|
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-
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|