3 namespace Zumba\GastonJS\Browser;
6 * Trait BrowserPageElementTrait
7 * @package Zumba\GastonJS\Browser
9 trait BrowserPageElementTrait {
11 * Find elements given a method and a selector
16 public function find($method, $selector) {
17 $result = $this->command('find', $method, $selector);
18 $found["page_id"] = $result["page_id"];
19 foreach ($result["ids"] as $id) {
20 $found["ids"][] = $id;
26 * Find elements within a page, method and selector
33 public function findWithin($pageId, $elementId, $method, $selector) {
34 return $this->command('find_within', $pageId, $elementId, $method, $selector);
42 public function getParents($pageId, $elementId) {
43 return $this->command('parents', $pageId, $elementId);
47 * Returns the text of a given page and element
52 public function allText($pageId, $elementId) {
53 return $this->command('all_text', $pageId, $elementId);
57 * Returns the inner or outer html of the given page and element
62 * @throws \Zumba\GastonJS\Exception\BrowserError
65 public function allHtml($pageId, $elementId, $type = "inner") {
66 return $this->command('all_html', $pageId, $elementId, $type);
70 * Returns ONLY the visible text of a given page and element
75 public function visibleText($pageId, $elementId) {
76 return $this->command('visible_text', $pageId, $elementId);
80 * Deletes the text of a given page and element
85 public function deleteText($pageId, $elementId) {
86 return $this->command('delete_text', $pageId, $elementId);
90 * Gets the tag name of a given element and page
95 public function tagName($pageId, $elementId) {
96 return strtolower($this->command('tag_name', $pageId, $elementId));
100 * Check if two elements are the same on a give
106 public function equals($pageId, $firstId, $secondId) {
107 return $this->command('equals', $pageId, $firstId, $secondId);
111 * Returns the attributes of an element in a given page
116 public function attributes($pageId, $elementId) {
117 return $this->command('attributes', $pageId, $elementId);
121 * Returns the attribute of an element by name in a given page
127 public function attribute($pageId, $elementId, $name) {
128 return $this->command('attribute', $pageId, $elementId, $name);
132 * Set an attribute to the given element in the given page
138 * @throws \Zumba\GastonJS\Exception\BrowserError
141 public function setAttribute($pageId, $elementId, $name, $value) {
142 return $this->command('set_attribute', $pageId, $elementId, $name, $value);
146 * Remove an attribute for a given page and element
151 * @throws \Zumba\GastonJS\Exception\BrowserError
154 public function removeAttribute($pageId, $elementId, $name) {
155 return $this->command('remove_attribute', $pageId, $elementId, $name);
159 * Checks if an element is visible or not
164 public function isVisible($pageId, $elementId) {
165 return $this->command("visible", $pageId, $elementId);
169 * Sends the order to execute a key event on a given element
177 public function keyEvent($pageId, $elementId, $keyEvent, $key, $modifier) {
178 return $this->command("key_event", $pageId, $elementId, $keyEvent, $key, $modifier);
182 * Sends the command to select and option given a value
186 * @param bool $multiple
189 public function selectOption($pageId, $elementId, $value, $multiple = false) {
190 return $this->command("select_option", $pageId, $elementId, $value, $multiple);