Class: Async::WebDriver::Element::Attributes
- Inherits:
-
Object
- Object
- Async::WebDriver::Element::Attributes
- Includes:
- Enumerable
- Defined in:
- lib/async/webdriver/element.rb
Overview
Attributes associated with an element.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Get the value of an attribute.
-
#[]=(name, value) ⇒ Object
Set the value of an attribute.
-
#each(&block) ⇒ Object
Iterate over all attributes.
-
#initialize(element) ⇒ Attributes
constructor
Initialize the attribute wrapper for an element.
-
#key?(name) ⇒ Boolean
Check if an attribute exists.
-
#keys ⇒ Object
Get the names of all attributes.
Constructor Details
#initialize(element) ⇒ Attributes
Initialize the attribute wrapper for an element.
25 26 27 28 |
# File 'lib/async/webdriver/element.rb', line 25 def initialize(element) @element = element @keys = nil end |
Instance Method Details
#[](name) ⇒ Object
Get the value of an attribute.
33 34 35 |
# File 'lib/async/webdriver/element.rb', line 33 def [](name) @element.attribute(name) end |
#[]=(name, value) ⇒ Object
Set the value of an attribute.
40 41 42 |
# File 'lib/async/webdriver/element.rb', line 40 def []=(name, value) @element.set_attribute(name, value) end |
#each(&block) ⇒ Object
Iterate over all attributes.
60 61 62 63 64 65 66 |
# File 'lib/async/webdriver/element.rb', line 60 def each(&block) return to_enum unless block_given? keys.each do |key| yield key, self[key] end end |
#key?(name) ⇒ Boolean
Check if an attribute exists.
52 53 54 |
# File 'lib/async/webdriver/element.rb', line 52 def key?(name) @element.execute("return this.hasAttribute(...arguments)", name) end |
#keys ⇒ Object
Get the names of all attributes.
45 46 47 |
# File 'lib/async/webdriver/element.rb', line 45 def keys @element.execute("return this.getAttributeNames()") end |