-
-
Notifications
You must be signed in to change notification settings - Fork 28
Move administrator login to the current page object pattern #42
Changes from all commits
da50914
f907231
8abb62a
a8665e9
595e022
a5660fa
41450eb
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
namespace Page\Acceptance\Administrator; | ||
|
||
use Page\Acceptance\Administrator\AdminPage; | ||
|
||
class ControlPanelPage extends AdminPage | ||
{ | ||
public static $url = "/administrator/index.php"; | ||
|
||
public static $pageTitle = 'Control Panel'; | ||
|
||
public static $pageTitleContext = ['class' => 'page-title']; | ||
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 probably still for an array here.. As else wise we are going to have thousands of public static (readability?) in pages. public static $usefulAndShortVariableName = [
'url' => '/administrator/index.php',
'pageTitle' => 'Control Panel',
'pageTitleContext' => ['class' => 'page-title'];
]; (Better indention on the elements, GitHub does not allow me to) // cc @javigomez, @pritalpatel, @nibra, @puneet0191 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. Imo this array should be even private / protected. And we would have a method We could also make an additional shortcut method, like we have in Joomla with for example JText::_, so you later only 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. I like the locator method idea, but then I don't know how we will be able to do this: https://www.youtube.com/watch?v=dV7fVtRz1SE 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. @javigomez not sure if i understand you. public static $usefulAndShortVariableName = [
'articleTitleField' => ['id' => 'jform_title'],
// ...
];
$I->fillField(Article::_('articleTitleField'), $title); You can have an array locator in an array. Or do you mean something different? 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 mean that with your IDE, right now you can see the value of 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. @javigomez you are right, you would need to Ctrl+click on Article (or ControlPanelPage in your sample). And then look at the array (or search with Ctrl+F for articleTitleField). PhpStorm / Shortcut trick (almost as fast as Ctrl+Click) Shortcut lovers, can do the following: Highlight / mark articleTitleField and do 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. An alternative would also be to override 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 reading it and understand what is the idea. But I am not sure which will be best for now. I think for now best and easy to work with imo is to use property instead of array and I have also found similar approach in other languages examples while I was reading about page objects. 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 don't think the array / locator approach improves the readability. You still have a list of identifiers. If they are variables or array indices does not make any difference in that regard. 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. Issue created for this topic at #55. I will not include the locator method in the present pull in order to fix one issue per pull. |
||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
namespace Step\Acceptance\Administrator; | ||
|
||
use Page\Acceptance\Administrator\LoginPage; | ||
use Page\Acceptance\Administrator\ControlPanelPage; | ||
|
||
class Login extends \AcceptanceTester | ||
{ | ||
/** | ||
* @When I Login into Joomla administrator with username :arg1 and password :arg1 | ||
*/ | ||
public function loginIntoJoomlaAdministrator($username, $password) | ||
{ | ||
$I = $this; | ||
$I->amOnPage(LoginPage::$url); | ||
$I->fillField(LoginPage::$usernameField, $username); | ||
$I->fillField(LoginPage::$passwordField, $password); | ||
$I->click(LoginPage::$loginButton); | ||
} | ||
|
||
/** | ||
* @Then I should see the administrator dashboard | ||
* @When I see the administrator dashboard | ||
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. We could add a regex here or just add the two gherkin sentences that will call the Step method. See: http://codeception.com/docs/07-BDD#step-definitions I took the option of adding the two sentences. |
||
*/ | ||
public function iShouldSeeTheAdministratorDashboard() | ||
{ | ||
$I = $this; | ||
$I->waitForPageTitle(ControlPanelPage::$pageTitle, 60, ControlPanelPage::$pageTitleContext); | ||
$I->see(ControlPanelPage::$pageTitle, ControlPanelPage::$pageTitleContext); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,6 @@ error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED" | |
gherkin: | ||
contexts: | ||
default: | ||
- AcceptanceTester | ||
- Step\Acceptance\Administrator\Login | ||
- Step\Acceptance\Administrator\User | ||
- Page\Acceptance\Administrator\Login | ||
- Step\Acceptance\Administrator\Content | ||
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. Also have to put,
otherwise it will show missing snippet error. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,5 @@ Feature: administrator login | |
I need to have a control panel | ||
|
||
Scenario: Login in Administrator | ||
Given Joomla CMS is installed | ||
When Login into Joomla administrator with username "admin" and password "admin" | ||
Then I see administrator dashboard | ||
When I Login into Joomla administrator with username "admin" and password "admin" | ||
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. Note that there is no Given anymore in this User Story. |
||
Then I should see the administrator dashboard |
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.
I'm removing this HTML5 attribute that was added with this idea: joomla/joomla-cms#10589
But the current agreement is that we are not going to use this attributes unless is really needed. So for the moment we will use the existing IDs for locating the elements and use the AdministratorLogin Page Object to store the locators.