Esempio n. 1
0
 /**
  * @param  Webdriver                 $driver    Driver for this test.
  * @param  JoomlaWebdriverTestClass  $test      Test class object (needed to create page class objects)
  * @param  string                    $url       Optional URL to load when object is created. Only use for initial page load.
  */
 public function __construct(Webdriver $driver, $test, $url = null)
 {
     $this->driver = $driver;
     $this->test = $test;
     $cfg = new SeleniumConfig();
     $this->cfg = $cfg;
     // save current configuration
     if ($url) {
         $this->driver->get($url);
     }
     $element = $driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath), 5);
     if (isset($this->url)) {
         $test->assertStringEndsWith($this->url, $driver->getCurrentPageUrl(), 'URL for page does not match expected value.');
     }
 }
Esempio n. 2
0
 /**
  * constructor function
  *
  * @param   Webdriver                 $driver  Driver for this test.
  * @param   JoomlaWebdriverTestClass  $test    Test class object (needed to create page class objects)
  * @param   string                    $url     Optional URL to load when object is created. Only use for initial page load.
  */
 public function __construct(Webdriver $driver, $test, $url = null)
 {
     $this->driver = $driver;
     /* @var $test JoomlaWebdriverTestCase */
     $this->test = $test;
     $cfg = new SeleniumConfig();
     // Save current configuration
     $this->cfg = $cfg;
     if ($url) {
         $this->driver->get($url);
     }
     $element = $driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath), 5);
     if (isset($this->url)) {
         $test->assertContains($this->url, $driver->getCurrentPageUrl(), 'URL for page does not match expected value.');
     }
 }
 /**
  * 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;
     }
 }