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