Patched to Drupal 8.4.8 level. See https://www.drupal.org/sa-core-2018-004 and patch...
[yaffs-website] / vendor / jcalderonzumba / gastonjs / src / Browser / Browser.php
1 <?php
2
3 namespace Zumba\GastonJS\Browser;
4
5 /**
6  * Class Browser
7  * @package Zumba\GastonJS
8  */
9 class Browser extends BrowserBase {
10
11   use BrowserAuthenticationTrait;
12   use BrowserConfigurationTrait;
13   use BrowserCookieTrait;
14   use BrowserFileTrait;
15   use BrowserFrameTrait;
16   use BrowserHeadersTrait;
17   use BrowserMouseEventTrait;
18   use BrowserNavigateTrait;
19   use BrowserNetworkTrait;
20   use BrowserPageElementTrait;
21   use BrowserPageTrait;
22   use BrowserRenderTrait;
23   use BrowserScriptTrait;
24   use BrowserWindowTrait;
25
26   /**
27    * @param string $phantomJSHost
28    * @param mixed  $logger
29    */
30   public function __construct($phantomJSHost, $logger = null) {
31     $this->phantomJSHost = $phantomJSHost;
32     $this->logger = $logger;
33     $this->debug = false;
34     $this->createApiClient();
35   }
36
37   /**
38    * Returns the value of a given element in a page
39    * @param $pageId
40    * @param $elementId
41    * @return mixed
42    */
43   public function value($pageId, $elementId) {
44     return $this->command('value', $pageId, $elementId);
45   }
46
47   /**
48    * Sets a value to a given element in a given page
49    * @param $pageId
50    * @param $elementId
51    * @param $value
52    * @return mixed
53    */
54   public function set($pageId, $elementId, $value) {
55     return $this->command('set', $pageId, $elementId, $value);
56   }
57
58   /**
59    * Tells whether an element on a page is visible or not
60    * @param $pageId
61    * @param $elementId
62    * @return bool
63    */
64   public function isVisible($pageId, $elementId) {
65     return $this->command('visible', $pageId, $elementId);
66   }
67
68   /**
69    * @param $pageId
70    * @param $elementId
71    * @return bool
72    */
73   public function isDisabled($pageId, $elementId) {
74     return $this->command('disabled', $pageId, $elementId);
75   }
76
77   /**
78    * Drag an element to a another in a given page
79    * @param $pageId
80    * @param $fromId
81    * @param $toId
82    * @return mixed
83    */
84   public function drag($pageId, $fromId, $toId) {
85     return $this->command('drag', $pageId, $fromId, $toId);
86   }
87
88   /**
89    * Selects a value in the given element and page
90    * @param $pageId
91    * @param $elementId
92    * @param $value
93    * @return mixed
94    */
95   public function select($pageId, $elementId, $value) {
96     return $this->command('select', $pageId, $elementId, $value);
97   }
98
99   /**
100    * Triggers an event to a given element on the given page
101    * @param $pageId
102    * @param $elementId
103    * @param $event
104    * @return mixed
105    */
106   public function trigger($pageId, $elementId, $event) {
107     return $this->command('trigger', $pageId, $elementId, $event);
108   }
109
110   /**
111    * TODO: not sure what this does, needs to do normalizeKeys
112    * @param int   $pageId
113    * @param int   $elementId
114    * @param array $keys
115    * @return mixed
116    */
117   public function sendKeys($pageId, $elementId, $keys) {
118     return $this->command('send_keys', $pageId, $elementId, $this->normalizeKeys($keys));
119   }
120 }