public function testIncorrectJsonButton()
 {
     $this->enable_compression_sizes(array());
     $this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
     $this->enable_compression_sizes(array('medium', 'large'));
     $this->set_api_key('JSON1234');
     self::$driver->get(wordpress('/wp-admin/upload.php'));
     self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images button'))->click();
     self::$driver->wait(2)->until(WebDriverExpectedCondition::textToBePresentInElement(WebDriverBy::cssSelector('td.tiny-compress-images'), 'JSON: Syntax error [4]'));
 }
 public function testCompressButton()
 {
     $this->enable_compression_sizes(array('medium'));
     $this->set_api_key('PNG123');
     $this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
     $this->enable_compression_sizes(array('medium', 'large'));
     self::$driver->get(wordpress('/wp-admin/upload.php'));
     $this->assertContains('Compressed 1 out of 2 sizes', self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images'))->getText());
     self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images button'))->click();
     self::$driver->wait(2)->until(WebDriverExpectedCondition::textToBePresentInElement(WebDriverBy::cssSelector('td.tiny-compress-images'), 'Compressed 2 out of 2 sizes'));
 }
 public function testBulkCompressShouldCompressAll()
 {
     $this->prepare(1, 1);
     self::$driver->get(wordpress('/wp-admin/upload.php?page=tiny-bulk-compress.php'));
     $elements = self::$driver->findElements(WebDriverBy::cssSelector('#tiny-bulk-compress p'));
     $this->assertContains('2 images', $elements[1]->getText());
     self::$driver->findElement(WebDriverBy::cssSelector('#tiny-bulk-compress button'))->click();
     self::$driver->wait(2)->until(WebDriverExpectedCondition::textToBePresentInElement(WebDriverBy::cssSelector('.updated'), 'All images are processed'));
     $elements = self::$driver->findElements(WebDriverBy::cssSelector('.media-item .filename'));
     $filenames = array_map('innerText', $elements);
     $this->assertEquals(2, count($filenames));
     $this->assertContains('input-large', $filenames);
     $this->assertContains('input-example', $filenames);
     $this->assertEquals('2', self::$driver->findElement(WebDriverBy::cssSelector('#tiny-progress span'))->getText());
     $this->assertEquals('5', self::$driver->findElement(WebDriverBy::cssSelector('#tiny-status span'))->getText());
 }
Esempio n. 4
0
 /**
  * Waits for text to appear on the page for a specific amount of time.
  * Can also be passed a selector to search in.
  * If text does not appear, timeout exception is thrown.
  *
  * ``` php
  * <?php
  * $I->waitForText('foo', 30); // secs
  * $I->waitForText('foo', 30, '.title'); // secs
  * ?>
  * ```
  *
  * @param string $text
  * @param int $timeout seconds
  * @param null $selector
  * @throws \Exception
  * @internal param string $element
  */
 public function waitForText($text, $timeout = 10, $selector = null)
 {
     $condition = null;
     if (!$selector) {
         $condition = \WebDriverExpectedCondition::textToBePresentInElement(\WebDriverBy::xpath('//body'), $text);
     } else {
         if (Locator::isID($selector)) {
             $condition = \WebDriverExpectedCondition::textToBePresentInElement(\WebDriverBy::id(substr($selector, 1)), $text);
         }
         if (!$condition and Locator::isCSS($selector)) {
             $condition = \WebDriverExpectedCondition::textToBePresentInElement(\WebDriverBy::cssSelector($selector), $text);
         }
         if (Locator::isXPath($selector)) {
             $condition = \WebDriverExpectedCondition::textToBePresentInElement(\WebDriverBy::xpath($selector), $text);
         }
         if (!$condition) {
             throw new \Exception("Only CSS or XPath allowed");
         }
     }
     $this->webDriver->wait($timeout)->until($condition);
 }
Esempio n. 5
0
 /**
  * Waits up to $timeout seconds for the given string to appear on the page.
  * Can also be passed a selector to search in.
  * If the given text doesn't appear, a timeout exception is thrown.
  *
  * ``` php
  * <?php
  * $I->waitForText('foo', 30); // secs
  * $I->waitForText('foo', 30, '.title'); // secs
  * ?>
  * ```
  *
  * @param string $text
  * @param int $timeout seconds
  * @param null $selector
  * @throws \Exception
  */
 public function waitForText($text, $timeout = 10, $selector = null)
 {
     if (!$selector) {
         $condition = \WebDriverExpectedCondition::textToBePresentInElement(\WebDriverBy::xpath('//body'), $text);
         $this->webDriver->wait($timeout)->until($condition);
         return;
     }
     $condition = \WebDriverExpectedCondition::textToBePresentInElement($this->getLocator($selector), $text);
     $this->webDriver->wait($timeout)->until($condition);
 }
 public function testShouldShowCorrectNoImageSizesInfo()
 {
     $elements = self::$driver->findElements(WebDriverBy::xpath('//input[@type="checkbox" and starts-with(@name, "tinypng_sizes") and @checked="checked"]'));
     foreach ($elements as $element) {
         $element->click();
     }
     self::$driver->wait(2)->until(WebDriverExpectedCondition::textToBePresentInElement(WebDriverBy::cssSelector('#tiny-image-sizes-notice'), 'Each selected size counts as a compression. With these settings no images will be compressed.'));
     // Not really necessary anymore to assert this.
     $elements = self::$driver->findElement(WebDriverBy::id('tiny-image-sizes-notice'))->findElements(WebDriverBy::tagName('p'));
     $statuses = array_map('innerText', $elements);
     $this->assertContains('Each selected size counts as a compression. With these settings no images will be compressed.', $statuses);
 }
Esempio n. 7
0
 /**
  * @param string $selector
  * @param string $text
  * @param int $timeout
  */
 public function waitForText($selector, $text, $timeout = null)
 {
     $this->_wait($timeout)->until(\WebDriverExpectedCondition::textToBePresentInElement($this->_getWebDriverBy($selector), $text));
 }
Esempio n. 8
0
 public function testBuildUpload()
 {
     $this->driver->get('http://localhost:80/builds/upload.php');
     $status = $this->driver->findElement(WebDriverBy::id("uploadStatus"));
     $this->assertContains("Upload a Build", $status->getText());
     $buildname = $this->driver->findElement(WebDriverBy::id("buildname"));
     $buildname->sendKeys("asdf");
     $filename = $this->driver->findElement(WebDriverBy::id("filename"));
     $filename->sendKeys("gioeunfa");
     $description = $this->driver->findElement(WebDriverBy::id("description"));
     $description->sendKeys("ghaseguiahgkareguhlgiuwf");
     $this->assertEquals("gioeunfa.bls", $filename->getAttribute("value"));
     $filename->sendKeys(KEYS::ENTER);
     $this->driver->wait(5, 250)->until(WebDriverExpectedCondition::textToBePresentInElement(WebDriverBy::id("uploadStatus"), "No file was selected to be uploaded"));
     $this->assertContains("No file was selected to be uploaded", $status->getText());
     $file = $this->driver->findElement(WebDriverBy::id("uploadfile"));
     $file->sendKeys(dirname(__DIR__) . "/res/some ramps.bls");
     $filename->sendKeys(KEYS::ENTER);
     $this->driver->wait(5, 250)->until(WebDriverExpectedCondition::not(WebDriverExpectedCondition::titleIs("Build Upload")));
 }
 public function testShouldNotShowResizingWhenOriginalDisabled()
 {
     $element = self::$driver->findElement(WebDriverBy::id('tinypng_sizes_0'));
     if ($element->getAttribute('checked')) {
         $element->click();
     }
     self::$driver->wait(1)->until(WebDriverExpectedCondition::textToBePresentInElement(WebDriverBy::cssSelector('p.tiny-resize-unavailable'), 'Enable the compression of the original image size to configure resizing.'));
     $labels = self::$driver->findElements(WebDriverBy::tagName('label'));
     $texts = array_map('innerText', $labels);
     $this->assertNotContains('Resize and compress orginal images to fit within:', $texts);
 }