Async::WebDriverSourceAsyncWebDriverElementAttributes

class Attributes

Attributes associated with an element.

Definitions

def initialize(element)

Initialize the attribute wrapper for an element.

Signature

parameter element Element

The element whose attributes will be accessed.

Implementation

def initialize(element)
	@element = element
	@keys = nil
end

def [](name)

Get the value of an attribute.

Signature

parameter name String

The name of the attribute.

returns Object

The value of the attribute with the given name.

Implementation

def [](name)
	@element.attribute(name)
end

def []=(name, value)

Set the value of an attribute.

Signature

parameter name String

The name of the attribute.

parameter value Object

The value of the attribute.

Implementation

def []=(name, value)
	@element.set_attribute(name, value)
end

def keys

Get the names of all attributes.

Implementation

def keys
	@element.execute("return this.getAttributeNames()")
end

def key?(name)

Check if an attribute exists.

Signature

parameter name String

The name of the attribute.

returns Boolean

True if the attribute exists.

Implementation

def key?(name)
	@element.execute("return this.hasAttribute(...arguments)", name)
end

def each(&block)

Iterate over all attributes.

Signature

yields {|name, value| ...}

The name and value of each attribute.

parameter name String

The name of the attribute.

parameter value Object

The value of the attribute.

Implementation

def each(&block)
	return to_enum unless block_given?
	
	keys.each do |key|
		yield key, self[key]
	end
end