-
-
Notifications
You must be signed in to change notification settings - Fork 28
Implementing Gherkin with codeception #18
Changes from all commits
64404e3
fb1d48f
f041222
7a73da2
529559e
4644e29
0bc9f11
ca40bee
d9a2dbb
219adc4
285802d
8696495
4adc554
de373a2
51059f6
368e052
2af2954
3b2c3e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,150 @@ | |
* @method void am($role) | ||
* @method void lookForwardTo($achieveValue) | ||
* @method void comment($description) | ||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) | ||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null) | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
*/ | ||
class AcceptanceTester extends \Codeception\Actor | ||
{ | ||
use _generated\AcceptanceTesterActions; | ||
use _generated\AcceptanceTesterActions; | ||
|
||
/** | ||
* Define custom actions here | ||
*/ | ||
/** | ||
* Method is to set Wait for page title | ||
* | ||
* @param string $title Page Title text | ||
* @param integer $timeout timeout time | ||
* | ||
* @return void | ||
*/ | ||
public function waitForPageTitle($title, $timeout = 60) | ||
{ | ||
$I = $this; | ||
$I->waitForText($title, $timeout, ['class' => 'page-title']); | ||
} | ||
|
||
/** | ||
* Function to check for PHP Notices or Warnings | ||
* | ||
* @param string $page Optional, if not given checks will be done in the current page | ||
* | ||
* @note: doAdminLogin() before | ||
*/ | ||
public function checkForPhpNoticesOrWarnings($page = null) | ||
{ | ||
$I = $this; | ||
|
||
if ($page) | ||
{ | ||
$I->amOnPage($page); | ||
} | ||
|
||
$I->dontSeeInPageSource('Notice:'); | ||
$I->dontSeeInPageSource('<b>Notice</b>:'); | ||
$I->dontSeeInPageSource('Warning:'); | ||
$I->dontSeeInPageSource('<b>Warning</b>:'); | ||
$I->dontSeeInPageSource('Strict standards:'); | ||
$I->dontSeeInPageSource('<b>Strict standards</b>:'); | ||
$I->dontSeeInPageSource('The requested page can\'t be found'); | ||
} | ||
|
||
/** | ||
* Function to select Toolbar buttons in Joomla! Admin Toolbar Panel | ||
* | ||
* @param string $button The full name of the button | ||
*/ | ||
public function clickToolbarButton($button) | ||
{ | ||
$I = $this; | ||
$input = strtolower($button); | ||
|
||
// @todo Needs to find way to work with different window size. | ||
/*$screenSize = explode("x", $this->config['window_size']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not able to get configuration using
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pritalpatel You have to move / copy the window_size in the configuration (acceptance.suite.yml) from JoomlaBrowser to AcceptanceHelper. |
||
if($screenSize[0] <= 480) | ||
{ | ||
$I->click('Toolbar'); | ||
}*/ | ||
|
||
switch($input) | ||
{ | ||
case "new": | ||
$I->click(['xpath' => "//div[@id='toolbar-new']//button"]); | ||
break; | ||
case "edit": | ||
$I->click(['xpath' => "//div[@id='toolbar-edit']//button"]); | ||
break; | ||
case "publish": | ||
$I->click(['xpath' => "//div[@id='toolbar-publish']//button"]); | ||
break; | ||
case "unpublish": | ||
$I->click(['xpath' => "//div[@id='toolbar-unpublish']//button"]); | ||
break; | ||
case "archive": | ||
$I->click(['xpath' => "//div[@id='toolbar-archive']//button"]); | ||
break; | ||
case "check-in": | ||
$I->click(['xpath' => "//div[@id='toolbar-checkin']//button"]); | ||
break; | ||
case "batch": | ||
$I->click(['xpath' => "//div[@id='toolbar-batch']//button"]); | ||
break; | ||
case "rebuild": | ||
$I->click(['xpath' => "//div[@id='toolbar-refresh']//button"]); | ||
break; | ||
case "trash": | ||
$I->click(['xpath' => "//div[@id='toolbar-trash']//button"]); | ||
break; | ||
case "save": | ||
$I->click(['xpath' => "//div[@id='toolbar-apply']//button"]); | ||
break; | ||
case "save & close": | ||
$I->click(['xpath' => "//div[@id='toolbar-save']//button"]); | ||
break; | ||
case "save & new": | ||
$I->click(['xpath' => "//div[@id='toolbar-save-new']//button"]); | ||
break; | ||
case "cancel": | ||
$I->click(['xpath' => "//div[@id='toolbar-cancel']//button"]); | ||
break; | ||
case "options": | ||
$I->click(['xpath' => "//div[@id='toolbar-options']//button"]); | ||
break; | ||
case "empty trash": | ||
$I->click(['xpath' => "//div[@id='toolbar-delete']//button"]); | ||
break; | ||
} | ||
} | ||
|
||
/** | ||
* Function to select all the item in the Search results in Administrator List | ||
* | ||
* Note: We recommend use of checkAllResults function only after searchForItem to be sure you are selecting only the desired result set | ||
* | ||
* @return void | ||
*/ | ||
public function checkAllResults() | ||
{ | ||
$I = $this; | ||
//$this->debug("Selecting Checkall button"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you have to enable Assert module in your acceptance suite file, see mine
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure, Why do you want to Debug? you could use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @puneet0191 I am using |
||
$I->click(['xpath' => "//thead//input[@name='checkall-toggle' or @name='toggle']"]); | ||
} | ||
|
||
/** | ||
* Selects an option in a Chosen Selector based on its id | ||
* | ||
* @param string $selectId The id of the <select> element | ||
* @param string $option The text in the <option> to be selected in the chosen selector | ||
* | ||
* @return void | ||
*/ | ||
public function selectOptionInChosenById($selectId, $option) | ||
{ | ||
$chosenSelectID = $selectId . '_chzn'; | ||
$I = $this; | ||
//$this->debug("I open the $chosenSelectID chosen selector"); | ||
$I->click(['xpath' => "//div[@id='$chosenSelectID']/a/div/b"]); | ||
//$this->debug("I select $option"); | ||
$I->click(['xpath' => "//div[@id='$chosenSelectID']//li[text()='$option']"]); | ||
$I->wait(1); // Gives time to chosen to close | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method /**
* @Then I see article unpublish message :arg1
*/
public function iSeeArticleUnpublishMessage($arg1) No need to be done now, but if you identify common patterns, maybe we can reconsider them for refactor and make them reusable: public function iSeeMessage($message)
{
$I = $this;
$I->waitForElement(['id' => 'system-message-container'], 60);
$I->see($message, ['id' => 'system-message-container']);
} |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our AcceptanceTester is starting to grow. Instead I would suggest that you start moving the methods into Pages and Steps.
https://github.com/Codeception/Codeception/blob/master/docs/07-BDD.md#configuration
See example at https://github.com/joomla-projects/gsoc16_browser-automated-tests/pull/15/files#diff-0a4914515e2c67ed1abfc54b96e7df28R39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yes i will start moving it into pages and step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javigomez I have moved content and user feature in their own steps.