-
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,6 @@ | ||
<?php | ||
use Behat\Mink\Exception\DriverException; | ||
use Behat\Mink\Selector\Xpath\Escaper; | ||
use WebDriver\Element; | ||
use \Behat\Mink\Element\NodeElement; | ||
use WebDriver\Exception\NoSuchElement; | ||
use WebDriver\Exception\UnknownCommand; | ||
use WebDriver\Exception\UnknownError; | ||
use WebDriver\Exception; | ||
use WebDriver\Key; | ||
use WebDriver\WebDriver; | ||
use WebDriver\Exception\UnexpectedAlertOpen; | ||
|
||
use Behat\Behat\Context\Context; | ||
|
||
use Behat\Mink\Exception\ExpectationException; | ||
use Behat\MinkExtension\Context\MinkContext; | ||
use Behat\MinkExtension\Context\RawMinkContext; | ||
|
||
use Behat\Gherkin\Node\TableNode; | ||
use Behat\Mink\Exception\ResponseTextException; | ||
use Behat\Mink\Exception\ElementNotFoundException; | ||
use WebDriver\Exception\StaleElementReference; | ||
use Behat\Behat\Tester\Exception\PendingException; | ||
|
||
|
||
// | ||
// Require 3rd-party libraries here: | ||
// | ||
// require_once 'PHPUnit/Autoload.php'; | ||
// require_once 'PHPUnit/Framework/Assert/Functions.php'; | ||
// | ||
use Behat\MinkExtension\Context\MinkContext; | ||
|
||
/** | ||
* Features context. | ||
|
@@ -85,6 +56,7 @@ public function __call($method, $parameters) | |
'The "%s()" method does not exist.', $method | ||
)); | ||
} | ||
|
||
/** | ||
* Everyone who tried Behat with Mink and a JavaScript driver (I use | ||
* Selenium2Driver with phantomjs) has had issues with trying to assert something | ||
|
@@ -116,6 +88,7 @@ protected function throwExpectationException($message) | |
{ | ||
throw new ExpectationException($message, $this->getSession()); | ||
} | ||
|
||
/** | ||
* @When something long is taking long but should output :text | ||
*/ | ||
|
@@ -139,17 +112,7 @@ public function doSomethingNotThereYet() | |
$button->click(); | ||
}); | ||
} | ||
// | ||
// Place your definition and hook methods here: | ||
// | ||
// /** | ||
// * @Given /^I have done something with "([^"]*)"$/ | ||
// */ | ||
// public function iHaveDoneSomethingWith($argument) | ||
// { | ||
// doSomethingWith($argument); | ||
// } | ||
// | ||
|
||
/** | ||
* @Given /^I have logged in as an administrator$/ | ||
*/ | ||
|
@@ -197,13 +160,15 @@ public function iFillInWithAValidUsername($arg1) | |
{ | ||
$this->fillField($arg1, $this->params['admin_username']); | ||
} | ||
|
||
/** | ||
* @When I fill in :arg1 with a valid password | ||
*/ | ||
public function iFillInWithAValidPassword($arg1) | ||
{ | ||
$this->fillField($arg1, $this->params['admin_password']); | ||
} | ||
|
||
/** | ||
* @When /^I fill in "([^"]*)" with an email address$/ | ||
*/ | ||
|
@@ -212,6 +177,7 @@ public function iFillInWithAnEmailAddress($fieldName) | |
$this->data['email'] = '[email protected]'; // at some point really make random | ||
$this->fillField($fieldName, $this->data['email']); | ||
} | ||
|
||
/** | ||
* @Given I fill in :arg1 with :arg2 emails | ||
*/ | ||
|
@@ -224,34 +190,14 @@ public function iFillInWithEmails($arg1, $arg2) | |
$this->fillField($arg1, $content); | ||
} | ||
|
||
|
||
/** | ||
* @Given /^I should see the email address I entered$/ | ||
*/ | ||
public function iShouldSeeTheEmailAddressIEntered() | ||
{ | ||
$this->assertSession()->pageTextContains($this->data['email']); | ||
} | ||
/** | ||
* @Given /^No campaigns yet exist$/ | ||
*/ | ||
public function iHaveNotYetCreatedCampaigns() | ||
{ | ||
// Count the number of campaigns in phplist_message table | ||
$result = mysqli_fetch_assoc( | ||
mysqli_query( | ||
$this->db,' | ||
select | ||
count(*) as count | ||
from | ||
phplist_message; | ||
') | ||
); | ||
$campaignCount = $result['count']; | ||
if ($campaignCount > 0) { | ||
$this->throwExpectationException('One or more campagins already exist'); | ||
} | ||
} | ||
|
||
/** | ||
* @Given /^I have subscriber with email "([^"]*)"/ | ||
*/ | ||
|
@@ -260,14 +206,6 @@ public function iHaveSubscriber($email) | |
$this->clickLink('S'); | ||
} | ||
|
||
/** | ||
* @return mysqli | ||
*/ | ||
public function getMysqli() | ||
{ | ||
return $this->db; | ||
} | ||
|
||
/** | ||
* @var array $params | ||
* @return string | ||
|
@@ -304,34 +242,19 @@ public function iWaitForTheAjaxResponse() | |
$this->getSession()->wait(5000, '(0 === jQuery.active)'); | ||
} | ||
|
||
/** | ||
* @When I switch to iframe :arg1 | ||
*/ | ||
public function iSwitchToIframe($arg1) | ||
{ $arg1=$this->find("css",'cke_wysiwyg_frame cke_reset'); | ||
$this->getSession()->switchToIFrame($arg1); | ||
|
||
} | ||
|
||
/** | ||
* Go back to main document frame. | ||
* | ||
* @When (I )switch to main frame | ||
*/ | ||
public function switchToMainFrame() | ||
{ | ||
$this->getSession()->getDriver()->switchToDefaultContent(); | ||
} | ||
|
||
/** | ||
* @Then I click on :arg1 | ||
*/ | ||
public function iClickOn($arg1) | ||
{ $arg1= $this->find("css",'submit btn btn-primary'); | ||
$this->getSession()->click($arg1); | ||
{ | ||
$arg1= $this->find("css",'submit btn btn-primary'); | ||
$this->getSession()->click($arg1); | ||
} | ||
/** | ||
|
||
/** | ||
* @When I enter text :arg1 | ||
* | ||
* requires the CKEDITOR, which is not there by default | ||
*/ | ||
public function iEnterText($arg1) | ||
{ | ||
|
@@ -340,10 +263,11 @@ public function iEnterText($arg1) | |
(function(){ | ||
CKEDITOR.instances.message.setData( '<p>This is the editor data.</p>' ); })(); | ||
JS; | ||
//$this->getSession()->executeScript("document.body.innerHTML = '<p>".$arg1."</p>'");} | ||
$this->getSession()->evaluateScript($script); | ||
//$this->getSession()->executeScript("document.body.innerHTML = '<p>".$arg1."</p>'");} | ||
$this->getSession()->evaluateScript($script); | ||
} | ||
/** | ||
|
||
/** | ||
* @Then I should read :arg1 | ||
*/ | ||
public function iShouldRead($arg1) | ||
|
@@ -353,32 +277,31 @@ public function iShouldRead($arg1) | |
CKEDITOR.instances.message.getData();})(); | ||
JS; | ||
$this->getSession()->evaluateScript($script); | ||
$this->getSession()->evaluateScript($script); | ||
} | ||
/** | ||
|
||
/** | ||
* @Then :arg1 checkbox should be checked | ||
*/ | ||
|
||
/** | ||
|
||
/** | ||
* @Then /^Radio button with id "([^"]*)" should be checked$/ | ||
*/ | ||
public function RadioButtonWithIdShouldBeChecked($sId) | ||
{ | ||
$elementByCss = $this->getSession()->getPage()->find('css', 'input[type="radio"]:checked#'.$sId); | ||
// if (!$elementByCss) { | ||
// throw new Exception('Radio button with id ' . $sId.' is not checked'); | ||
// } | ||
} | ||
|
||
/** | ||
public function RadioButtonWithIdShouldBeChecked($sId) | ||
{ | ||
$elementByCss = $this->getSession()->getPage()->find('css', 'input[type="radio"]:checked#'.$sId); | ||
} | ||
|
||
/** | ||
* @When I switch back from iframe | ||
*/ | ||
public function iSwitchBackFrom($name=null) | ||
{ | ||
$this->getSession()->getDriver()->switchToIframe(null); | ||
} | ||
|
||
/** | ||
/** | ||
* @Then I switch to other iframe :arg1 | ||
*/ | ||
public function iSwitchToOtherIframe($arg1) | ||
|
@@ -399,7 +322,7 @@ public function iMouseOver($arg1) | |
$findName->mouseOver(); | ||
} | ||
} | ||
/** | ||
/** | ||
* @Given I click over :arg1 | ||
*/ | ||
public function iClickOver($arg1) | ||
|
@@ -410,45 +333,45 @@ public function iClickOver($arg1) | |
} | ||
|
||
/** | ||
* @Given I write :text into :field | ||
*/ | ||
public function iWriteTextIntoField($text, $field) | ||
{ | ||
$field = $this->getSession() | ||
->getDriver() | ||
->getWebDriverSession() | ||
->element('xpath', '//*[@id="edit_list_categories"]/div/input'); | ||
$field->postValue(['value' => [$text]]); | ||
} | ||
* @Given I write :text into :field | ||
*/ | ||
public function iWriteTextIntoField($text, $field) | ||
{ | ||
$field = $this->getSession() | ||
->getDriver() | ||
->getWebDriverSession() | ||
->element('xpath', '//*[@id="edit_list_categories"]/div/input'); | ||
$field->postValue(['value' => [$text]]); | ||
} | ||
|
||
|
||
/** | ||
* @Given I go back | ||
*/ | ||
/** | ||
* @Given I go back | ||
*/ | ||
public function iGoBack() | ||
{ | ||
$this->getSession()->getDriver()->back(); | ||
} | ||
|
||
/** | ||
* @When I confirm the popup | ||
*/ | ||
/** | ||
* @When I confirm the popup | ||
*/ | ||
public function iConfirmThePopup() | ||
{ | ||
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert(); | ||
} | ||
|
||
/** | ||
* @Given I go back to :arg1 | ||
*/ | ||
/** | ||
* @Given I go back to :arg1 | ||
*/ | ||
public function iGoBackTo($page) | ||
{ | ||
$this->getSession()->getDriver()->back(); | ||
} | ||
|
||
/** | ||
* @Then The header color should be black | ||
*/ | ||
/** | ||
* @Then The header color should be black | ||
*/ | ||
public function theDivContextMenuBlockMenuColorShouldBeBlack() | ||
{ | ||
|
||
|
@@ -464,12 +387,13 @@ public function theDivContextMenuBlockMenuColorShouldBeBlack() | |
throw new Exception(); | ||
} | ||
} | ||
/** | ||
* @Then I should see :message on popups | ||
*/ | ||
|
||
/** | ||
* @Then I should see :message on popups | ||
*/ | ||
public function iShouldSeeOnPopups($message) | ||
{ return $message == $this->getSession()->getDriver()->getWebDriverSession()->getAlert_text(); | ||
|
||
{ | ||
return $message == $this->getSession()->getDriver()->getWebDriverSession()->getAlert_text(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters