3 * Copyright 2004-2017 Facebook. All Rights Reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * @author Justin Bishop <jubishop@gmail.com>
20 * @author Anthon Pang <apang@softwaredevelopment.ca>
21 * @author Fabrizio Branca <mail@fabrizio-branca.de>
27 * WebDriver\Element class
31 * @method void click() Click on an element.
32 * @method void submit() Submit a FORM element.
33 * @method string text() Returns the visible text for the element.
34 * @method void postValue($json) Send a sequence of key strokes to an element.
35 * @method string name() Query for an element's tag name.
36 * @method void clear() Clear a TEXTAREA or text INPUT element's value.
37 * @method boolean selected() Determine if an OPTION element, or an INPUT element of type checkbox or radiobutton is currently selected.
38 * @method boolean enabled() Determine if an element is currently enabled.
39 * @method string attribute($attributeName) Get the value of an element's attribute.
40 * @method boolean equals($otherId) Test if two element IDs refer to the same DOM element.
41 * @method boolean displayed() Determine if an element is currently displayed.
42 * @method array location() Determine an element's location on the page.
43 * @method array location_in_view() Determine an element's location on the screen once it has been scrolled into view.
44 * @method array size() Determine an element's size in pixels.
45 * @method string css($propertyName) Query the value of an element's computed CSS property.
47 final class Element extends Container
52 protected function methods()
55 'click' => array('POST'),
56 'submit' => array('POST'),
57 'text' => array('GET'),
58 'value' => array('POST'),
59 'name' => array('GET'),
60 'clear' => array('POST'),
61 'selected' => array('GET'),
62 'enabled' => array('GET'),
63 'attribute' => array('GET'),
64 'equals' => array('GET'),
65 'displayed' => array('GET'),
66 'location' => array('GET'),
67 'location_in_view' => array('GET'),
68 'size' => array('GET'),
69 'css' => array('GET'),
76 protected function obsoleteMethods()
79 'value' => array('GET'),
80 'selected' => array('POST'),
81 'toggle' => array('POST'),
82 'hover' => array('POST'),
83 'drag' => array('POST'),
97 * @param string $url URL
98 * @param string $id element ID
100 public function __construct($url, $id)
102 parent::__construct($url);
112 public function getID()
120 protected function getElementPath($elementId)
122 return preg_replace(sprintf('/%s$/', $this->id), $elementId, $this->url);