annotate vendor/instaclick/php-webdriver/lib/WebDriver/Element.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
rev   line source
Chris@0 1 <?php
Chris@0 2 /**
Chris@0 3 * Copyright 2004-2017 Facebook. All Rights Reserved.
Chris@0 4 *
Chris@0 5 * Licensed under the Apache License, Version 2.0 (the "License");
Chris@0 6 * you may not use this file except in compliance with the License.
Chris@0 7 * You may obtain a copy of the License at
Chris@0 8 *
Chris@0 9 * http://www.apache.org/licenses/LICENSE-2.0
Chris@0 10 *
Chris@0 11 * Unless required by applicable law or agreed to in writing, software
Chris@0 12 * distributed under the License is distributed on an "AS IS" BASIS,
Chris@0 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Chris@0 14 * See the License for the specific language governing permissions and
Chris@0 15 * limitations under the License.
Chris@0 16 *
Chris@0 17 * @package WebDriver
Chris@0 18 *
Chris@0 19 * @author Justin Bishop <jubishop@gmail.com>
Chris@0 20 * @author Anthon Pang <apang@softwaredevelopment.ca>
Chris@0 21 * @author Fabrizio Branca <mail@fabrizio-branca.de>
Chris@0 22 */
Chris@0 23
Chris@0 24 namespace WebDriver;
Chris@0 25
Chris@0 26 /**
Chris@0 27 * WebDriver\Element class
Chris@0 28 *
Chris@0 29 * @package WebDriver
Chris@0 30 *
Chris@0 31 * @method void click() Click on an element.
Chris@0 32 * @method void submit() Submit a FORM element.
Chris@0 33 * @method string text() Returns the visible text for the element.
Chris@0 34 * @method void postValue($json) Send a sequence of key strokes to an element.
Chris@0 35 * @method string name() Query for an element's tag name.
Chris@0 36 * @method void clear() Clear a TEXTAREA or text INPUT element's value.
Chris@0 37 * @method boolean selected() Determine if an OPTION element, or an INPUT element of type checkbox or radiobutton is currently selected.
Chris@0 38 * @method boolean enabled() Determine if an element is currently enabled.
Chris@0 39 * @method string attribute($attributeName) Get the value of an element's attribute.
Chris@0 40 * @method boolean equals($otherId) Test if two element IDs refer to the same DOM element.
Chris@0 41 * @method boolean displayed() Determine if an element is currently displayed.
Chris@0 42 * @method array location() Determine an element's location on the page.
Chris@0 43 * @method array location_in_view() Determine an element's location on the screen once it has been scrolled into view.
Chris@0 44 * @method array size() Determine an element's size in pixels.
Chris@0 45 * @method string css($propertyName) Query the value of an element's computed CSS property.
Chris@0 46 */
Chris@0 47 final class Element extends Container
Chris@0 48 {
Chris@0 49 /**
Chris@0 50 * {@inheritdoc}
Chris@0 51 */
Chris@0 52 protected function methods()
Chris@0 53 {
Chris@0 54 return array(
Chris@0 55 'click' => array('POST'),
Chris@0 56 'submit' => array('POST'),
Chris@0 57 'text' => array('GET'),
Chris@0 58 'value' => array('POST'),
Chris@0 59 'name' => array('GET'),
Chris@0 60 'clear' => array('POST'),
Chris@0 61 'selected' => array('GET'),
Chris@0 62 'enabled' => array('GET'),
Chris@0 63 'attribute' => array('GET'),
Chris@0 64 'equals' => array('GET'),
Chris@0 65 'displayed' => array('GET'),
Chris@0 66 'location' => array('GET'),
Chris@0 67 'location_in_view' => array('GET'),
Chris@0 68 'size' => array('GET'),
Chris@0 69 'css' => array('GET'),
Chris@0 70 );
Chris@0 71 }
Chris@0 72
Chris@0 73 /**
Chris@0 74 * {@inheritdoc}
Chris@0 75 */
Chris@0 76 protected function obsoleteMethods()
Chris@0 77 {
Chris@0 78 return array(
Chris@0 79 'value' => array('GET'),
Chris@0 80 'selected' => array('POST'),
Chris@0 81 'toggle' => array('POST'),
Chris@0 82 'hover' => array('POST'),
Chris@0 83 'drag' => array('POST'),
Chris@0 84 );
Chris@0 85 }
Chris@0 86
Chris@0 87 /**
Chris@0 88 * Element ID
Chris@0 89 *
Chris@0 90 * @var string
Chris@0 91 */
Chris@0 92 private $id;
Chris@0 93
Chris@0 94 /**
Chris@0 95 * Constructor
Chris@0 96 *
Chris@0 97 * @param string $url URL
Chris@0 98 * @param string $id element ID
Chris@0 99 */
Chris@0 100 public function __construct($url, $id)
Chris@0 101 {
Chris@0 102 parent::__construct($url);
Chris@0 103
Chris@0 104 $this->id = $id;
Chris@0 105 }
Chris@0 106
Chris@0 107 /**
Chris@0 108 * Get element ID
Chris@0 109 *
Chris@0 110 * @return string
Chris@0 111 */
Chris@0 112 public function getID()
Chris@0 113 {
Chris@0 114 return $this->id;
Chris@0 115 }
Chris@0 116
Chris@0 117 /**
Chris@0 118 * {@inheritdoc}
Chris@0 119 */
Chris@0 120 protected function getElementPath($elementId)
Chris@0 121 {
Chris@0 122 return preg_replace(sprintf('/%s$/', $this->id), $elementId, $this->url);
Chris@0 123 }
Chris@0 124 }