This repository was archived by the owner on Mar 17, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 28
Codeception Gherkin Experiment #22
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ac3e34d
First attempt with Gherkin
puneet0191 c9dcc92
Updating Locators, My Life should become easy not hard
puneet0191 618a714
Composer is good, Composer is bad
puneet0191 d621b5b
Only File which excites me to work on Gherkin
puneet0191 1f75f5e
Updating file structure for my new proposal
puneet0191 34d0b65
Adding Admin Page Class File
puneet0191 327b972
Adding Login Page Class File
puneet0191 c9eb12c
Updating Joomla Step File
puneet0191 8f89fef
Adding Article manager Page File
puneet0191 25aafcf
Content Step File
puneet0191 4ef1495
Updating NameSpace
puneet0191 657a26e
Updating Login Step Class File
puneet0191 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
tests/_support/Page/Acceptance/Joomla3/Administrator/AdminPage.php
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
namespace Page\Acceptance\Joomla3\Administrator; | ||
|
||
class AdminPage extends \AcceptanceTester | ||
{ | ||
public static $systemMessageContainer = ['id' => 'system-message-container']; | ||
|
||
public static $pageTitle = ['class' => 'page-title']; | ||
|
||
public static $controlPanelText = "Control Panel"; | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/_support/Page/Acceptance/Joomla3/Administrator/ArticleManagerPage.php
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
namespace Page\Acceptance\Joomla3\Administrator; | ||
|
||
use Page\Acceptance\Joomla3\Administrator\AdminPage; | ||
|
||
class ArticleManagerPage extends AdminPage | ||
{ | ||
public static $articleTitleField = ['id' => 'jform_title']; | ||
|
||
public static $articleContentField = ['id' => 'jform_articletext']; | ||
|
||
public static $toggleEditor = "Toggle editor"; | ||
|
||
public static $pageURL = "/administrator/index.php?option=com_content&view=articles"; | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/_support/Page/Acceptance/Joomla3/Administrator/LoginPage.php
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
namespace Page\Acceptance\Joomla3\Administrator; | ||
|
||
use Page\Acceptance\Joomla3\Administrator\AdminPage; | ||
|
||
class LoginPage extends AdminPage | ||
{ | ||
public static $usernameField = ['id' => 'mod-login-username']; | ||
|
||
public static $passwordField = ['id' => 'mod-login-password']; | ||
|
||
public static $pageTitle = ['class' => 'page-title']; | ||
|
||
public static $loginButton = ['xpath' => "//button[contains(normalize-space(), 'Log in')]"]; | ||
|
||
public static $pageURL = "/administrator/index.php"; | ||
} |
55 changes: 55 additions & 0 deletions
55
tests/_support/Step/Acceptance/Joomla3/Administrator/ContentSteps.php
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Step\Acceptance\Joomla3\Administrator; | ||
|
||
use Page\Acceptance\Joomla3\Administrator\ArticleManagerPage; | ||
|
||
class ContentSteps extends \AcceptanceTester | ||
{ | ||
/** | ||
* @Given There is a Add Content link | ||
*/ | ||
public function thereIsAAddContentLink() | ||
{ | ||
$I = $this; | ||
$I->amOnPage(ArticleManagerPage::$pageURL); | ||
$I->clickToolbarButton('New'); | ||
} | ||
|
||
/** | ||
* @When I fill mandatory fields for creating article | ||
*/ | ||
public function iFillMandatoryFieldsForCreatingArticle(\Behat\Gherkin\Node\TableNode $fields) | ||
{ | ||
$I = $this; | ||
// iterate over all rows | ||
foreach ($fields->getRows() as $index => $row) { | ||
if ($index === 0) { // first row to define fields | ||
$keys = $row; | ||
continue; | ||
} | ||
else | ||
{ | ||
if ($row[0] == "title") | ||
{ | ||
$I->fillField(ArticleManagerPage::$articleTitleField, $row[1]); | ||
} | ||
|
||
if ($row[0] == "content") | ||
{ | ||
$I->click(ArticleManagerPage::$toggleEditor); | ||
$I->fillField(ArticleManagerPage::$articleContentField, $row[1]); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @When I save an article | ||
*/ | ||
public function iSaveAnArticle() | ||
{ | ||
$I = $this; | ||
$I->clickToolbarButton('Save'); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
tests/_support/Step/Acceptance/Joomla3/Administrator/JoomlaSteps.php
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Step\Acceptance\Joomla3\Administrator; | ||
|
||
use Page\Acceptance\Joomla3\Administrator\AdminPage; | ||
|
||
class JoomlaSteps extends \AcceptanceTester | ||
{ | ||
/** | ||
* @Then I should see the :arg1 message | ||
*/ | ||
public function iShouldSeeTheMessage($message) | ||
{ | ||
$I = $this; | ||
$I->waitForPageTitle('Articles'); | ||
$I->see($message, AdminPage::$systemMessageContainer); | ||
|
||
} | ||
|
||
/** | ||
* @Given Joomla CMS is installed | ||
*/ | ||
public function joomlaCMSIsInstalled() | ||
{ | ||
$I = $this; | ||
|
||
} | ||
|
||
/** | ||
* @Then I see administrator dashboard | ||
*/ | ||
public function iSeeAdministratorDashboard() | ||
{ | ||
$I = $this; | ||
$I->waitForText(AdminPage::$controlPanelText, 4, AdminPage::$pageTitle); | ||
} | ||
|
||
/** | ||
* Method is to set Wait for page title | ||
* | ||
* @param string $title Page Title text | ||
* @param integer $timeout Waiting time | ||
* | ||
* @return void | ||
*/ | ||
private function waitForPageTitle($title, $timeout = 60) | ||
{ | ||
$I = $this; | ||
$I->waitForText($title, $timeout, AdminPage::$pageTitle); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/_support/Step/Acceptance/Joomla3/Administrator/LoginSteps.php
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Step\Acceptance\Joomla3\Administrator; | ||
|
||
use Page\Acceptance\Joomla3\Administrator\LoginPage; | ||
|
||
class LoginSteps extends \AcceptanceTester | ||
{ | ||
/** | ||
* @When Login into Joomla administrator with username :arg1 and password :arg1 | ||
*/ | ||
public function loginIntoJoomlaAdministratorWithUsernameAndPassword($arg1, $arg2) | ||
{ | ||
$I = $this; | ||
$I->amGoingTo('I open Joomla Administrator Login Page'); | ||
$I->amOnPage(LoginPage::$pageURL); | ||
$I->waitForElement(LoginPage::$usernameField, 60); | ||
$I->amGoingTo('Fill Username Text Field'); | ||
$I->fillField(LoginPage::$usernameField, $arg1); | ||
$I->amGoingTo('Fill Password Text Field'); | ||
$I->fillField(LoginPage::$passwordField, $arg2); | ||
|
||
$I->amGoingTo('I click LoginPage button'); | ||
$I->click(LoginPage::$loginButton); | ||
$I->amGoingTo('I wait to see Administrator Control Panel'); | ||
$I->waitForText(LoginPage::$controlPanelText, 10, LoginPage::$pageTitle); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...rt/Step/Acceptance/Administrator/User.php → ...Acceptance/Joomla3/Administrator/User.php
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Feature: content | ||
In order to manage content article in the web | ||
As an owner | ||
I need to create content article | ||
|
||
Background: | ||
Given Joomla CMS is installed | ||
When Login into Joomla administrator with username "puneet" and password "1234" | ||
Then I see administrator dashboard | ||
|
||
Scenario: Create an Article | ||
Given There is a Add Content link | ||
When I fill mandatory fields for creating article | ||
| field | value | | ||
| title | My_Article | | ||
| content | This is my First Article | | ||
And I save an article | ||
Then I should see the "Article successfully saved." message |
This file contains hidden or 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 |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
"php": ">=5.3.10" | ||
}, | ||
"require-dev": { | ||
"codeception/codeception": "master@dev", | ||
"codeception/codeception": "~2.2", | ||
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 have sent separate PR for the same. 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 But Puneet commited his composer.lock ;) |
||
"joomla-projects/joomla-browser": "v3.4.8.3", | ||
"joomla-projects/selenium-server-standalone": "v2.52.0", | ||
"codegyre/robo": "~0.6", | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
very cool!
But I would only use tables when we want to repeat the same test with different values.
Fore example: create 10 articles:
see:
