public function _afterSuite()
 {
     parent::_afterSuite();
     if ($this->bs_local) {
         $this->bs_local->stop();
     }
 }
Exemplo n.º 2
0
 public function testBug1637()
 {
     $this->module->amOnPage('/form/bug1637');
     // confirm that options outside a form are still selectable
     $this->module->selectOption('input[name=first_test_radio]', 'Yes');
     // confirm that it did what we expected and did not do anything else
     $this->module->seeOptionIsSelected('input[name=first_test_radio]', 'Yes');
     $this->module->dontSeeOptionIsSelected('input[name=first_test_radio]', 'No');
 }
Exemplo n.º 3
0
 public function testAppendFieldDiv()
 {
     $this->module->amOnPage('/form/div_content_editable');
     //make sure we see 'sunrise' which is the default text in the textarea
     $this->module->see('sunrise', '#description');
     //fill in some new text and see if we can see it
     $textarea_value = 'moonrise';
     $this->module->appendField('#description', $textarea_value);
     $this->module->see('sunrise' . $textarea_value, '#description');
 }
Exemplo n.º 4
0
 public function testSessionSnapshots()
 {
     $this->module->amOnPage('/');
     $this->module->setCookie('PHPSESSID', '123456', ['path' => '/']);
     $this->module->saveSessionSnapshot('login');
     $this->module->seeCookie('PHPSESSID');
     $this->webDriver->manage()->deleteAllCookies();
     $this->module->dontSeeCookie('PHPSESSID');
     $this->module->loadSessionSnapshot('login');
     $this->module->seeCookie('PHPSESSID');
 }
Exemplo n.º 5
0
 /**
  * Find the position and proportion of a DOM element, specified by it's ID.
  * The method inject the
  * JQuery Framework and uses the "noConflict"-mode to get the width, height and offset params.
  *
  * @param string $selector DOM ID/class of the element, which should be screenshotted
  * @return array coordinates of the element
  * @throws \Codeception\Exception\ElementNotFound
  */
 private function getCoordinates($selector = 'body')
 {
     try {
         $this->webDriverModule->waitForElementVisible($selector, 10);
         /** @var WebDriverElement|null $element */
         $element = $this->remoteWebDriver->findElement(WebDriverBy::cssSelector($selector));
     } catch (\Exception $e) {
         throw new ElementNotFound('Element ' . $selector . ' could not be located by WebDriver');
     }
     $elementSize = $element->getSize();
     $elementLocation = $element->getLocation();
     $imageCoords['x'] = $elementLocation->getX();
     $imageCoords['y'] = $elementLocation->getY();
     $imageCoords['width'] = $elementSize->getWidth();
     $imageCoords['height'] = $elementSize->getHeight();
     return $imageCoords;
 }
Exemplo n.º 6
0
 public function testWebDriverWaits()
 {
     $fakeWd = Stub::make('\\Codeception\\Module\\WebDriver', ['wait' => Stub::exactly(12, function () {
         return new \Codeception\Util\Maybe();
     })]);
     $this->module->webDriver = $fakeWd;
     $this->module->waitForElement(WebDriverBy::partialLinkText('yeah'));
     $this->module->waitForElement(['id' => 'user']);
     $this->module->waitForElement(['css' => '.user']);
     $this->module->waitForElement('//xpath');
     $this->module->waitForElementVisible(WebDriverBy::partialLinkText('yeah'));
     $this->module->waitForElementVisible(['id' => 'user']);
     $this->module->waitForElementVisible(['css' => '.user']);
     $this->module->waitForElementVisible('//xpath');
     $this->module->waitForElementNotVisible(WebDriverBy::partialLinkText('yeah'));
     $this->module->waitForElementNotVisible(['id' => 'user']);
     $this->module->waitForElementNotVisible(['css' => '.user']);
     $this->module->waitForElementNotVisible('//xpath');
 }
 /**
  * Will unhide the element for the given selector or unhide all elements that have been set to hidden before if
  * no selector is given.
  *
  * @param string|null $selector The selector of the element that should be unhidden nor null if all elements should
  * be unhidden that have been set to hidden before.
  */
 public function unhideElements($selector = null)
 {
     if ($selector === null) {
         foreach ($this->hiddenSuiteElements as $elementData) {
             $this->webDriver->webDriver->executeScript('arguments[0].style.visibility = \'' . $elementData['visibilityBackup'] . '\';', array($elementData['element']));
         }
         $this->hiddenSuiteElements = array();
     } else {
         $elements = $this->webDriver->_findElements($selector);
         foreach ($elements as $element) {
             if (isset($this->hiddenSuiteElements[$element->getID()])) {
                 $visibility = $this->hiddenSuiteElements[$element->getID()]['visibilityBackup'];
                 unset($this->hiddenSuiteElements[$element->getID()]);
             } else {
                 $visibility = 'visible';
             }
             $this->webDriver->webDriver->executeScript('arguments[0].style.visibility = \'' . $visibility . '\';', array($element));
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Constructor.
  *
  * @since 1.0.0
  *
  * @access public
  * @param array $config Configuration array.
  */
 public function __construct($config = null)
 {
     // remove "url" field from required fields because it will be automatically populated using home_url() function
     $url_index = array_search('url', $this->requiredFields);
     if (!empty($url_index)) {
         unset($this->requiredFields[$url_index]);
     }
     // add home url to the config
     $this->config['url'] = home_url();
     // call parent constructor
     parent::__construct($config);
     // add pahntomjs path if needed
     if ('phantomjs' == $this->config['browser']) {
         $phantomjs_binary = WPCC_ABSPATH . '/node_modules/phantomjs/bin/phantomjs';
         if (!isset($this->config['capabilities'])) {
             $this->config['capabilities'] = array('phantomjs.binary.path' => $phantomjs_binary);
         } elseif (empty($this->config['capabilities']['phantomjs.binary.path'])) {
             $this->config['capabilities']['phantomjs.binary.path'] = $phantomjs_binary;
         }
     }
 }
Exemplo n.º 9
0
 public function afterStep(StepEvent $e)
 {
     if (!$this->webDriverModule or !$this->dir) {
         return;
     }
     if ($e->getStep() instanceof CommentStep) {
         return;
     }
     $step = $e->getStep();
     if ($step->getAction() == "makeScreenshot") {
         $filename = str_pad($this->stepNum, 3, "0", STR_PAD_LEFT) . '.png';
         //echo "aa".$this->stepNum;
         //echo "bb".$filename;
         //echo "CC".$this->dir;
         //die();
         $this->webDriverModule->_saveScreenshot($this->dir . DIRECTORY_SEPARATOR . $filename);
         $this->stepNum++;
         $this->slides[$filename] = $e->getStep();
     }
 }
Exemplo n.º 10
0
 public function afterStep(StepEvent $e)
 {
     if (!$this->webDriverModule or !$this->dir) {
         return;
     }
     if ($e->getStep() instanceof CommentStep) {
         return;
     }
     $filename = str_pad($this->stepNum, 3, "0", STR_PAD_LEFT) . '.png';
     $this->webDriverModule->_saveScreenshot($this->dir . DIRECTORY_SEPARATOR . $filename);
     $this->stepNum++;
     $this->slides[$filename] = $e->getStep();
 }
Exemplo n.º 11
0
 public function testSeeElementMalformedWdLocator()
 {
     $this->setExpectedException('Codeception\\Exception\\MalformedLocator');
     $this->module->amOnPage('/');
     $this->module->seeElement(WebDriverBy::xpath('H---EY!'));
 }
Exemplo n.º 12
0
 /**
  * Override method to add test name to the capabilities.
  * Name will be shown in sauce labs / testing bot / browser stack services
  *
  * @param TestCase $test
  */
 public function _before(TestCase $test)
 {
     $this->config['capabilities']['name'] = get_class($test->getTestClass()) . ':' . $test->getName();
     parent::_before($test);
 }
Exemplo n.º 13
0
 /**
  * Constructor.
  *
  * @since 1.0.0
  *
  * @access public
  * @param array $config Configuration array.
  */
 public function __construct($config = null)
 {
     $this->requiredFields[] = 'username';
     $this->requiredFields[] = 'access_key';
     parent::__construct($config);
 }
Exemplo n.º 14
0
 public function testBug2046()
 {
     $this->module->webDriver = null;
     $this->module->_saveScreenshot(\Codeception\Configuration::outputDir() . 'testshot.png');
 }
Exemplo n.º 15
0
 /**
  * @Issue 2921
  */
 public function testSeeInFieldForTextarea()
 {
     $this->module->amOnPage('/form/bug2921');
     $this->module->seeInField('foo', 'bar baz');
 }
Exemplo n.º 16
0
 protected function notForPhantomJS()
 {
     if ($this->module->_getConfig('browser') == 'phantomjs') {
         $this->markTestSkipped('does not work for phantomjs');
     }
 }
Exemplo n.º 17
0
 protected function getStrictLocator(array $by)
 {
     $type = key($by);
     $value = $by[$type];
     if ($type === 'model') {
         return WebDriverBy::cssSelector(sprintf('[ng-model="%s"]', $value));
     }
     return parent::getStrictLocator($by);
 }
Exemplo n.º 18
0
 public function testEmptyFormSubmit()
 {
     $this->shouldFail();
     $this->module->amOnPage('/form/complex');
     $this->module->submitForm('form111', array());
 }
 /**
  * Initializes the module setting the properties values.
  * @return void
  */
 public function _initialize()
 {
     parent::_initialize();
     $this->loginUrl = str_replace('wp-admin', 'wp-login.php', $this->config['adminUrl']);
     $this->adminUrl = rtrim($this->config['adminUrl'], '/');
     $this->pluginsUrl = $this->adminUrl . '/plugins.php';
 }
Exemplo n.º 20
-1
 public function testSubmitUnchecked()
 {
     $this->module->amOnPage('/form/unchecked');
     $this->module->seeCheckboxIsChecked('#checkbox');
     $this->module->uncheckOption('#checkbox');
     $this->module->click('#submit');
     $this->module->see('0', '#notice');
 }
Exemplo n.º 21
-1
 public function testSaveSessionSnapshotsExcludeInvalidCookieDomains()
 {
     $fakeWdOptions = Stub::make('\\Facebook\\WebDriver\\WebDriverOptions', ['getCookies' => Stub::atLeastOnce(function () {
         return [['name' => 'PHPSESSID', 'value' => '123456', 'path' => '/'], ['name' => '3rdParty', 'value' => '_value_', 'path' => '/', 'domain' => '.3rd-party.net']];
     })]);
     $fakeWd = Stub::make('\\Facebook\\WebDriver\\Remote\\RemoteWebDriver', ['manage' => Stub::atLeastOnce(function () use($fakeWdOptions) {
         return $fakeWdOptions;
     })]);
     // Mock the WebDriverOptions::getCookies() method on the first call to introduce a 3rd-party cookie
     // which has to be ignored when saving a snapshot.
     $originalWebDriver = $this->module->webDriver;
     $this->module->webDriver = $fakeWd;
     $this->module->seeCookie('PHPSESSID');
     $this->module->seeCookie('3rdParty');
     $this->module->saveSessionSnapshot('login');
     // Restore the original WebDriver
     $this->module->webDriver = $originalWebDriver;
     $this->webDriver->manage()->deleteAllCookies();
     $this->module->dontSeeCookie('PHPSESSID');
     $this->module->dontSeeCookie('3rdParty');
     $this->module->loadSessionSnapshot('login');
     $this->module->seeCookie('PHPSESSID');
     $this->module->dontSeeCookie('3rdParty');
 }