예제 #1
0
 /**
  * @return $this
  */
 public function unpin()
 {
     $this->test->byXPath("//div[@class='top-action-box']//button[@class='btn minimize-button gold-icon']")->click();
     $this->waitPageToLoad();
     $this->waitForAjax();
     return $this;
 }
예제 #2
0
 protected function setUp()
 {
     parent::setUp();
     $this->setBrowser('firefox');
     $this->setHost('192.168.33.10');
     $this->setBrowserUrl('http://typo3-6-2.lamp2/');
 }
예제 #3
0
파일: WaitUntil.php 프로젝트: pdkhuong/BBG
 /**
  * @param $callback Callback to run until it returns not null or timeout occurs
  * @param null $timeout
  * @return mixed
  * @throws PHPUnit_Extensions_Selenium2TestCase_Exception
  * @throws PHPUnit_Extensions_Selenium2TestCase_WebDriverException
  */
 public function run($callback, $timeout = null)
 {
     if (!is_callable($callback)) {
         throw new PHPUnit_Extensions_Selenium2TestCase_Exception('The valid callback is expected');
     }
     // if there was an implicit timeout specified - remember it and temporarily turn it off
     $implicitWait = $this->_testCase->timeouts()->getLastImplicitWaitValue();
     if ($implicitWait) {
         $this->_testCase->timeouts()->implicitWait(0);
     }
     if (is_null($timeout)) {
         $timeout = $this->_defaultTimeout;
     }
     $timeout /= 1000;
     $endTime = microtime(true) + $timeout;
     $lastException = null;
     while (true) {
         try {
             $result = $callback($this->_testCase);
             if (!is_null($result)) {
                 return $result;
             }
         } catch (Exception $e) {
             $lastException = $e;
         }
         if (microtime(true) > $endTime) {
             if ($implicitWait) {
                 $this->_testCase->timeouts()->implicitWait($implicitWait);
             }
             $message = "Timed out after {$timeout} second" . ($timeout != 1 ? 's' : '');
             throw new PHPUnit_Extensions_Selenium2TestCase_WebDriverException($message, PHPUnit_Extensions_Selenium2TestCase_WebDriverException::Timeout, $lastException);
         }
         usleep($this->_defaultSleepInterval * 1000);
     }
 }
 /**
  * FIXED https://github.com/giorgiosironi/phpunit-selenium/issues/261
  *
  * "Unable to set Cookie: no URL has been loaded yet"
  * 
  * @return unknown
  */
 public function prepareSession()
 {
     $res = parent::prepareSession();
     $res->cookie()->remove('PHPUNIT_SELENIUM_TEST_ID');
     $this->url('/');
     return $res;
 }
예제 #5
0
 public function setUp()
 {
     parent::setUp();
     $this->setHost('home.brocode.dk');
     $this->setPort(4444);
     $this->setBrowser("internet explorer");
     $this->setBrowserUrl('http://localhost:9090/JoomlaTestCodeCeption/');
 }
 /**
  * Tests the _byMap method
  *
  * @covers ::_byMap
  * @return void
  */
 public function testByMap()
 {
     $this->page = $this->getMock('ExamplePagePublicElementMethods', null, array($this->test));
     $this->test->expects($this->once())->method('byCssSelector')->with($this->equalTo('field_2'))->will($this->returnValue('element'));
     $locator = $this->page->byMap('fieldTwo');
     $expected = 'element';
     $this->assertEquals($expected, $locator);
 }
	public function __construct()
	{
		parent::__construct();
		$this->screenshotUrl = $GLOBALS['XE_ROOT_URL'] . '/modules/shop/tests/logs/screenshots';
		$this->screenshotPath = dirname(__FILE__) . '/../logs/screenshots';
		$this->xe_root_url = $GLOBALS['XE_ROOT_URL'];
		$this->vid = $GLOBALS['XE_SHOP_VID'];
	}
예제 #8
0
 /**
  * Runs the test if the Selenium RC Server is reachable.
  *
  * If the server is not reachable, the tests will be marked as skipped, and
  * a message will be displayed giving a hint on which host/port the client
  * was looking for the Selenium server.
  *
  * @see PHPUnit_Extensions_SeleniumTestCase::runTest()
  *
  * @return void
  */
 protected function runTest()
 {
     if ($this->isSeleniumServerRunning()) {
         parent::runTest();
     } else {
         $this->markTestSkipped('Selenium RC server not reachable (host=' . $this->getSeleniumHost() . ', port=' . $this->getSeleniumPort() . ').');
     }
 }
 public function prepareSession()
 {
     $res = parent::prepareSession();
     if (defined('PHPUNIT_SELENIUM_COVERAGE')) {
         $res->cookie()->remove('PHPUNIT_SELENIUM_TEST_ID');
         $this->url('/');
     }
     return $res;
 }
예제 #10
0
 public function closeWidgetWindow()
 {
     $widgetCloseButton = "//div[starts-with(@class,'ui-dialog-titlebar ui-widget-header')]//button|span[contains(., 'close')]";
     while ($this->isElementPresent($widgetCloseButton)) {
         $this->test->byXPath($widgetCloseButton)->click();
         $this->waitForAjax();
     }
     return $this;
 }
예제 #11
0
 /**
  * Wait for the end of ajax by checking the data-loaded attribute
  *
  * @param string $id          the id of the ajax div
  * @param int    $waitTimeout timeout value
  *
  * @return void
  */
 public function waitForAjax($id, $waitTimeout = 10000)
 {
     parent::waitUntil(function () use($id) {
         // data-loaded attritude is added in url.js at onComplete event
         if ($this->byId($id)->attribute("data-loaded") == "1") {
             return true;
         }
         return null;
     }, $waitTimeout);
 }
예제 #12
0
 public function onNotSuccessfulTest(\Exception $e)
 {
     if ($this->captureScreenshotOnFailure) {
         $filename = $this->classPrefix . '__' . $this->getTestId() . '__' . date('Y-m-d\\TH-i-s');
         file_put_contents($this->screenshotPath . '/' . $filename . '.png', $this->currentScreenshot());
         file_put_contents($this->screenshotPath . '/' . $filename . '.html', $this->source());
         $e = new \PHPUnit_Extensions_Selenium2TestCase_Exception($e->getMessage() . "\nScreenshot name is {$filename}\n", $e->getCode(), $e);
     }
     parent::onNotSuccessfulTest($e);
 }
예제 #13
0
 public function __construct($name = NULL, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     // Make sure we are using the Appium session
     self::setUpSessionStrategy(array("sessionStrategy" => "isolated"));
     // Appium doesn't use the browser per se, but the system fails
     // if it is not set
     self::setBrowser("");
     self::setBrowserUrl("");
 }
예제 #14
0
 /**
  * Type text in textarea (CodeMirror enabled)
  *
  * @param string $text Text to type
  *
  * @return void
  */
 public function typeInTextArea($text)
 {
     $text = str_replace(
         "(",
         PHPUnit_Extensions_Selenium2TestCase_Keys::SHIFT
         . PHPUnit_Extensions_Selenium2TestCase_Keys::NUMPAD9
         . PHPUnit_Extensions_Selenium2TestCase_Keys::NULL,
         $text
     );
     $this->_selenium->byClassName("CodeMirror-scroll")->click();
     $this->_selenium->keys($text);
 }
예제 #15
0
 protected function setUp()
 {
     parent::setUp();
     // $this->setBrowser($this->getSeleniumBrowser());
     // $this->setHost($this->getSeleniumHost());
     // $this->setPort($this->getSeleniumPort());
     $this->setBrowser('chrome');
     $this->setHost('192.168.33.10');
     $this->setPort(4444);
     $this->setBrowserUrl('http://typo3-6-2.lamp2/');
     // Base url
 }
예제 #16
0
 /**
  * Sets up before each test method runs.
  * This mainly sets the base URL for the test application.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->setHost('localhost');
     $this->setPort(4444);
     $this->setBrowserUrl(TEST_BASE_URL);
     // $this->setBrowser('phantomjs');
     $this->setBrowser('firefox');
     // $this->setBrowser('chrome');
     // $this->setBrowser('*firefox');
     // $this->setBrowser('phantomjs');
     // $this->setBrowserUrl(TEST_BASE_URL);
 }
 public function select($selectSelector, $optionSelector)
 {
     $selectElement = parent::select($this->byQuery($selectSelector));
     if (preg_match('/label=(.+)/', $optionSelector, $match)) {
         $selectElement->selectOptionByLabel($match[1]);
     } else {
         if (preg_match('/value=(.+)/', $optionSelector, $match)) {
             $selectElement->selectOptionByValue($match[1]);
         } else {
             throw new \Exception("Unknown option selector '{$optionSelector}'");
         }
     }
 }
예제 #18
0
 public function setUp()
 {
     parent::setUp();
     $this->setBrowser('firefox');
     $this->setBrowserUrl(Mage::getBaseUrl());
     $this->setUpSessionStrategy(null);
     // Default Browser-Size
     $this->prepareSession()->currentWindow()->size(array('width' => 1280, 'height' => 1024));
     self::initFrontend(1);
     if (Mage::getIsDeveloperMode()) {
         self::$_defaultSleep = 7;
     }
     $this->disableCaches();
     $this->setConfigMagento();
     $this->setMundipaggConfig();
     $this->createSimpleProduct();
 }
예제 #19
0
파일: TestCase.php 프로젝트: nhp/Xtest
 protected function runTest()
 {
     try {
         return parent::runTest();
     } catch (Exception $e) {
         if (Xtest::getArg('debug')) {
             echo PHP_EOL . "got '" . $e->getMessage() . "' exception. press any key to continue.." . PHP_EOL;
             ob_end_flush();
             fgets(STDIN);
         }
         throw $e;
     }
 }
예제 #20
0
 /**
  * Wrapper around alertText method to not use it on not supported
  * browsers.
  *
  * @return void
  */
 public function alertText()
 {
     /**
      * Not supported in Safari Webdriver, see
      * http://code.google.com/p/selenium/issues/detail?id=4136
      */
     if ($GLOBALS['PMA_String']->strtolower($this->getBrowser()) == 'safari') {
         $this->markTestSkipped('Alerts not supported on Safari browser.');
     }
     return parent::alertText();
 }
 protected function setUpSessionStrategy($params)
 {
     // This logic enables us to have a session strategy reused for each
     // item in self::$browsers. We don't want them both to share one
     // and we don't want each test for a specific browser to have a
     // new strategy
     if ($params == self::$lastBrowserParams) {
         // do nothing so we use the same session strategy for this
         // browser
     } elseif (isset($params['sessionStrategy'])) {
         $strat = $params['sessionStrategy'];
         if ($strat != "isolated" && $strat != "shared") {
             throw new InvalidArgumentException("Session strategy must be either 'isolated' or 'shared'");
         } elseif ($strat == "isolated") {
             self::$browserSessionStrategy = new PHPUnit_Extensions_Selenium2TestCase_SessionStrategy_Isolated();
         } else {
             self::$browserSessionStrategy = new PHPUnit_Extensions_Selenium2TestCase_SessionStrategy_Shared(self::defaultSessionStrategy());
         }
     } else {
         self::$browserSessionStrategy = self::defaultSessionStrategy();
     }
     self::$lastBrowserParams = $params;
     $this->localSessionStrategy = self::$browserSessionStrategy;
 }
예제 #22
0
 protected function assertSelectedValue($id, $index)
 {
     $this->assertSame($index, parent::select($this->getElement($id))->selectedValue());
 }
 /**
  * Injects an untainted clone of the object manager and all its referencing
  * objects for every test.
  *
  * @return void
  */
 public function runBare()
 {
     $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->objectManager = clone $objectManager;
     parent::runBare();
 }
예제 #24
0
파일: Abstract.php 프로젝트: nhp/Xtest
 /**
  * @param $text
  * @param bool $exactOnly
  * @return PHPUnit_Extensions_Selenium2TestCase_Element
  * @throws Exception
  */
 public function byLinkText($text, $exactOnly = false)
 {
     try {
         return parent::byLinkText($text);
     } catch (Exception $e) {
         try {
             return parent::byLinkText(strtoupper($text));
         } catch (Exception $e) {
             $aTags = $this->findElementsByCssSelector('a');
             foreach ($aTags as $aTag) {
                 $aText = $aTag->text();
                 if (strtolower($aText) == strtolower($text)) {
                     return $aTag;
                 }
                 if (stripos($aText, $text) !== false) {
                     return $aTag;
                 }
             }
         }
         throw $e;
     }
 }
예제 #25
0
 protected function tearDown()
 {
     $this->cookie()->clear();
     parent::tearDown();
 }
예제 #26
0
 /**
  * Wrapper around alertText method to not use it on not supported
  * browsers.
  *
  * @return mixed
  */
 public function alertText()
 {
     /**
      * Not supported in Safari Webdriver, see
      * https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/4136
      */
     if (mb_strtolower($this->getBrowser()) == 'safari') {
         $this->markTestSkipped('Alerts not supported on Safari browser.');
     }
     return parent::alertText();
 }
 /**
  * Constructor
  *
  * @param	string	$name 
  * @param	array	$data 
  * @param	string	$dataName 
  */
 public function __construct($name = NULL, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     $this->CI =& get_instance();
     log_message('debug', get_class($this) . ' CIUnit_TestCase initialized');
 }
 private static function sessionStrategy()
 {
     if (!self::$sessionStrategy) {
         self::$sessionStrategy = self::defaultSessionStrategy();
     }
     return self::$sessionStrategy;
 }
<?php

use Tracy\Debugger;
use VersionPress\Tests\Selenium\SeleniumTestCase;
use VersionPress\Tests\Utils\TestConfig;
use VersionPress\Tests\Utils\TestRunnerOptions;
require_once __DIR__ . '/../vendor/autoload.php';
Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/../log');
TestRunnerOptions::getInstance()->configureInstance(["forceSetup" => ["before-class", "before-suite", "just-vp-files"]]);
TestConfig::$defaultConfigFile = __DIR__ . '/test-config.yml';
PHPUnit_Extensions_Selenium2TestCase::shareSession(true);
if (TestRunnerOptions::getInstance()->forceSetup == "before-suite") {
    echo "Setting up site before suite";
    SeleniumTestCase::setUpSite(true);
    echo "\n";
}
 /**
  * HACK for selenium error "Can only set Cookies for the current domain"
  *      when using phantomjs and generating code coverage
  */
 public function prepareSession()
 {
     $res = parent::prepareSession();
     $this->url('/');
     return $res;
 }