Chris@14: Chris@14: * @author Anthon Pang Chris@14: * @author Fabrizio Branca Chris@14: */ Chris@14: Chris@14: namespace WebDriver; Chris@14: Chris@14: /** Chris@14: * WebDriver\Element class Chris@14: * Chris@14: * @package WebDriver Chris@14: * Chris@14: * @method void click() Click on an element. Chris@14: * @method void submit() Submit a FORM element. Chris@14: * @method string text() Returns the visible text for the element. Chris@14: * @method void postValue($json) Send a sequence of key strokes to an element. Chris@14: * @method string name() Query for an element's tag name. Chris@14: * @method void clear() Clear a TEXTAREA or text INPUT element's value. Chris@14: * @method boolean selected() Determine if an OPTION element, or an INPUT element of type checkbox or radiobutton is currently selected. Chris@14: * @method boolean enabled() Determine if an element is currently enabled. Chris@14: * @method string attribute($attributeName) Get the value of an element's attribute. Chris@14: * @method boolean equals($otherId) Test if two element IDs refer to the same DOM element. Chris@14: * @method boolean displayed() Determine if an element is currently displayed. Chris@14: * @method array location() Determine an element's location on the page. Chris@14: * @method array location_in_view() Determine an element's location on the screen once it has been scrolled into view. Chris@14: * @method array size() Determine an element's size in pixels. Chris@14: * @method string css($propertyName) Query the value of an element's computed CSS property. Chris@14: */ Chris@14: final class Element extends Container Chris@14: { Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: protected function methods() Chris@14: { Chris@14: return array( Chris@14: 'click' => array('POST'), Chris@14: 'submit' => array('POST'), Chris@14: 'text' => array('GET'), Chris@14: 'value' => array('POST'), Chris@14: 'name' => array('GET'), Chris@14: 'clear' => array('POST'), Chris@14: 'selected' => array('GET'), Chris@14: 'enabled' => array('GET'), Chris@14: 'attribute' => array('GET'), Chris@14: 'equals' => array('GET'), Chris@14: 'displayed' => array('GET'), Chris@14: 'location' => array('GET'), Chris@14: 'location_in_view' => array('GET'), Chris@14: 'size' => array('GET'), Chris@14: 'css' => array('GET'), Chris@14: ); Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: protected function obsoleteMethods() Chris@14: { Chris@14: return array( Chris@14: 'value' => array('GET'), Chris@14: 'selected' => array('POST'), Chris@14: 'toggle' => array('POST'), Chris@14: 'hover' => array('POST'), Chris@14: 'drag' => array('POST'), Chris@14: ); Chris@14: } Chris@14: Chris@14: /** Chris@14: * Element ID Chris@14: * Chris@14: * @var string Chris@14: */ Chris@14: private $id; Chris@14: Chris@14: /** Chris@14: * Constructor Chris@14: * Chris@14: * @param string $url URL Chris@14: * @param string $id element ID Chris@14: */ Chris@14: public function __construct($url, $id) Chris@14: { Chris@14: parent::__construct($url); Chris@14: Chris@14: $this->id = $id; Chris@14: } Chris@14: Chris@14: /** Chris@14: * Get element ID Chris@14: * Chris@14: * @return string Chris@14: */ Chris@14: public function getID() Chris@14: { Chris@14: return $this->id; Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: protected function getElementPath($elementId) Chris@14: { Chris@14: return preg_replace(sprintf('/%s$/', $this->id), $elementId, $this->url); Chris@14: } Chris@14: }