annotate vendor/jcalderonzumba/gastonjs/src/Browser/BrowserPageElementTrait.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Zumba\GastonJS\Browser;
Chris@0 4
Chris@0 5 /**
Chris@0 6 * Trait BrowserPageElementTrait
Chris@0 7 * @package Zumba\GastonJS\Browser
Chris@0 8 */
Chris@0 9 trait BrowserPageElementTrait {
Chris@0 10 /**
Chris@0 11 * Find elements given a method and a selector
Chris@0 12 * @param $method
Chris@0 13 * @param $selector
Chris@0 14 * @return array
Chris@0 15 */
Chris@0 16 public function find($method, $selector) {
Chris@0 17 $result = $this->command('find', $method, $selector);
Chris@0 18 $found["page_id"] = $result["page_id"];
Chris@0 19 foreach ($result["ids"] as $id) {
Chris@0 20 $found["ids"][] = $id;
Chris@0 21 }
Chris@0 22 return $found;
Chris@0 23 }
Chris@0 24
Chris@0 25 /**
Chris@0 26 * Find elements within a page, method and selector
Chris@0 27 * @param $pageId
Chris@0 28 * @param $elementId
Chris@0 29 * @param $method
Chris@0 30 * @param $selector
Chris@0 31 * @return mixed
Chris@0 32 */
Chris@0 33 public function findWithin($pageId, $elementId, $method, $selector) {
Chris@0 34 return $this->command('find_within', $pageId, $elementId, $method, $selector);
Chris@0 35 }
Chris@0 36
Chris@0 37 /**
Chris@0 38 * @param $pageId
Chris@0 39 * @param $elementId
Chris@0 40 * @return mixed
Chris@0 41 */
Chris@0 42 public function getParents($pageId, $elementId) {
Chris@0 43 return $this->command('parents', $pageId, $elementId);
Chris@0 44 }
Chris@0 45
Chris@0 46 /**
Chris@0 47 * Returns the text of a given page and element
Chris@0 48 * @param $pageId
Chris@0 49 * @param $elementId
Chris@0 50 * @return mixed
Chris@0 51 */
Chris@0 52 public function allText($pageId, $elementId) {
Chris@0 53 return $this->command('all_text', $pageId, $elementId);
Chris@0 54 }
Chris@0 55
Chris@0 56 /**
Chris@0 57 * Returns the inner or outer html of the given page and element
Chris@0 58 * @param $pageId
Chris@0 59 * @param $elementId
Chris@0 60 * @param $type
Chris@0 61 * @return mixed
Chris@0 62 * @throws \Zumba\GastonJS\Exception\BrowserError
Chris@0 63 * @throws \Exception
Chris@0 64 */
Chris@0 65 public function allHtml($pageId, $elementId, $type = "inner") {
Chris@0 66 return $this->command('all_html', $pageId, $elementId, $type);
Chris@0 67 }
Chris@0 68
Chris@0 69 /**
Chris@0 70 * Returns ONLY the visible text of a given page and element
Chris@0 71 * @param $pageId
Chris@0 72 * @param $elementId
Chris@0 73 * @return mixed
Chris@0 74 */
Chris@0 75 public function visibleText($pageId, $elementId) {
Chris@0 76 return $this->command('visible_text', $pageId, $elementId);
Chris@0 77 }
Chris@0 78
Chris@0 79 /**
Chris@0 80 * Deletes the text of a given page and element
Chris@0 81 * @param $pageId
Chris@0 82 * @param $elementId
Chris@0 83 * @return mixed
Chris@0 84 */
Chris@0 85 public function deleteText($pageId, $elementId) {
Chris@0 86 return $this->command('delete_text', $pageId, $elementId);
Chris@0 87 }
Chris@0 88
Chris@0 89 /**
Chris@0 90 * Gets the tag name of a given element and page
Chris@0 91 * @param $pageId
Chris@0 92 * @param $elementId
Chris@0 93 * @return string
Chris@0 94 */
Chris@0 95 public function tagName($pageId, $elementId) {
Chris@0 96 return strtolower($this->command('tag_name', $pageId, $elementId));
Chris@0 97 }
Chris@0 98
Chris@0 99 /**
Chris@0 100 * Check if two elements are the same on a give
Chris@0 101 * @param $pageId
Chris@0 102 * @param $firstId
Chris@0 103 * @param $secondId
Chris@0 104 * @return bool
Chris@0 105 */
Chris@0 106 public function equals($pageId, $firstId, $secondId) {
Chris@0 107 return $this->command('equals', $pageId, $firstId, $secondId);
Chris@0 108 }
Chris@0 109
Chris@0 110 /**
Chris@0 111 * Returns the attributes of an element in a given page
Chris@0 112 * @param $pageId
Chris@0 113 * @param $elementId
Chris@0 114 * @return mixed
Chris@0 115 */
Chris@0 116 public function attributes($pageId, $elementId) {
Chris@0 117 return $this->command('attributes', $pageId, $elementId);
Chris@0 118 }
Chris@0 119
Chris@0 120 /**
Chris@0 121 * Returns the attribute of an element by name in a given page
Chris@0 122 * @param $pageId
Chris@0 123 * @param $elementId
Chris@0 124 * @param $name
Chris@0 125 * @return mixed
Chris@0 126 */
Chris@0 127 public function attribute($pageId, $elementId, $name) {
Chris@0 128 return $this->command('attribute', $pageId, $elementId, $name);
Chris@0 129 }
Chris@0 130
Chris@0 131 /**
Chris@0 132 * Set an attribute to the given element in the given page
Chris@0 133 * @param $pageId
Chris@0 134 * @param $elementId
Chris@0 135 * @param $name
Chris@0 136 * @param $value
Chris@0 137 * @return mixed
Chris@0 138 * @throws \Zumba\GastonJS\Exception\BrowserError
Chris@0 139 * @throws \Exception
Chris@0 140 */
Chris@0 141 public function setAttribute($pageId, $elementId, $name, $value) {
Chris@0 142 return $this->command('set_attribute', $pageId, $elementId, $name, $value);
Chris@0 143 }
Chris@0 144
Chris@0 145 /**
Chris@0 146 * Remove an attribute for a given page and element
Chris@0 147 * @param $pageId
Chris@0 148 * @param $elementId
Chris@0 149 * @param $name
Chris@0 150 * @return mixed
Chris@0 151 * @throws \Zumba\GastonJS\Exception\BrowserError
Chris@0 152 * @throws \Exception
Chris@0 153 */
Chris@0 154 public function removeAttribute($pageId, $elementId, $name) {
Chris@0 155 return $this->command('remove_attribute', $pageId, $elementId, $name);
Chris@0 156 }
Chris@0 157
Chris@0 158 /**
Chris@0 159 * Checks if an element is visible or not
Chris@0 160 * @param $pageId
Chris@0 161 * @param $elementId
Chris@0 162 * @return boolean
Chris@0 163 */
Chris@0 164 public function isVisible($pageId, $elementId) {
Chris@0 165 return $this->command("visible", $pageId, $elementId);
Chris@0 166 }
Chris@0 167
Chris@0 168 /**
Chris@0 169 * Sends the order to execute a key event on a given element
Chris@0 170 * @param $pageId
Chris@0 171 * @param $elementId
Chris@0 172 * @param $keyEvent
Chris@0 173 * @param $key
Chris@0 174 * @param $modifier
Chris@0 175 * @return mixed
Chris@0 176 */
Chris@0 177 public function keyEvent($pageId, $elementId, $keyEvent, $key, $modifier) {
Chris@0 178 return $this->command("key_event", $pageId, $elementId, $keyEvent, $key, $modifier);
Chris@0 179 }
Chris@0 180
Chris@0 181 /**
Chris@0 182 * Sends the command to select and option given a value
Chris@0 183 * @param $pageId
Chris@0 184 * @param $elementId
Chris@0 185 * @param $value
Chris@0 186 * @param bool $multiple
Chris@0 187 * @return mixed
Chris@0 188 */
Chris@0 189 public function selectOption($pageId, $elementId, $value, $multiple = false) {
Chris@0 190 return $this->command("select_option", $pageId, $elementId, $value, $multiple);
Chris@0 191 }
Chris@0 192
Chris@0 193 }