Example #1
0
 /**
  * Sends text to alert input
  * @param String $value
  */
 public function setAlertValue($value)
 {
     // validate that value is string
     $command = "alert_text";
     $params = array('text' => $value);
     $urlHubFormatted = $this->_hubUrl . "/session/{$this->_sessionId}/{$command}";
     $httpClient = HttpFactory::getClient($this->_environment);
     $httpClient->setUrl($urlHubFormatted)->setHttpMethod(HttpClient::POST)->setJsonParams($params)->execute();
 }
 /**
  * Takes screenshot of current screen, saves it in specified default directory or as specified in parameter
  * @param String $folder
  * @throws \Exception
  * @return string
  */
 public function helpScreenshot($fileName, $folder = null)
 {
     $this->driver->setCurrentWindowSize(1280, 1024);
     $screenshotsDirectory = null;
     if (isset($folder)) {
         $screenshotsDirectory = $folder;
     } else {
         if ($this->driver->getScreenShotsDirectory()) {
             $screenshotsDirectory = $this->driver->getScreenShotsDirectory();
         } else {
             throw new \Exception("Must Specify Screenshot Directory");
         }
     }
     $command = "screenshot";
     $urlHubFormatted = $this->driver->getHubUrl() . "/session/{$this->driver->getSessionId()}/{$command}";
     $httpClient = HttpFactory::getClient($this->driver->getEnvironment());
     $results = $httpClient->setUrl($urlHubFormatted)->setHttpMethod(HttpClient::GET)->execute();
     if (isset($results["value"]) && trim($results["value"]) != "") {
         if (!file_exists($screenshotsDirectory)) {
             mkdir($screenshotsDirectory, 0777, true);
         }
         file_put_contents($screenshotsDirectory . "/" . $fileName, base64_decode($results["value"]));
         return $fileName;
     }
 }