Skip to content

Commit

Permalink
Element::attribute() and Element::property() work differently
Browse files Browse the repository at this point in the history
  • Loading branch information
robocoder committed Dec 4, 2023
1 parent 99b3135 commit 631d363
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions lib/WebDriver/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*
* @package WebDriver
*
* @method string attribute($attributeName) Get the value of an element's attribute.
* @method void clear() Clear a TEXTAREA or text INPUT element's value.
* @method void click() Click on an element.
* @method boolean displayed() Determine if an element is currently displayed.
Expand All @@ -25,7 +24,6 @@
* @method array location() Determine an element's location on the page.
* @method array location_in_view() Determine an element's location on the screen once it has been scrolled into view.
* @method string name() Query for an element's tag name.
* @method array property($propertyName) Get element property.
* @method array rect() Get element rect.
* @method array screenshot() Take element screenshot.
* @method array selected() Is element selected?
Expand All @@ -51,12 +49,10 @@ class Element extends Container
protected function methods()
{
return array(
'attribute' => array('GET'),
'clear' => array('POST'),
'click' => array('POST'),
'enabled' => array('GET'),
'name' => array('GET'),
'property' => array('GET'),
'rect' => array('GET'),
'screenshot' => array('GET'),
'selected' => array('GET'),
Expand Down Expand Up @@ -113,6 +109,20 @@ public function getID()
return $this->id;
}

/**
* Get the value of an element's attribute: /session/:sessionId/element/:id/attribute/:name
*
* @param string name
*
* @return mixed
*/
public function attribute($name)
{
$result = $this->curl('GET', "/attribute/$name");

return $result['value'];
}

/**
* Query the value of an element’s computed CSS property: /session/:sessionId/element/:id/css/:propertyName
*
Expand All @@ -127,6 +137,20 @@ public function css($propertyName)
return $result['value'];
}

/**
* Get element property: /session/:sessionId/element/:id/property/:name
*
* @param string $name
*
* @return mixed
*/
public function property($name)
{
$result = $this->curl('GET', "/property/$name");

return $result['value'];
}

/**
* Get element shadow root: /session/:sessionId/element/:elementId/shadow
*
Expand Down

0 comments on commit 631d363

Please sign in to comment.