Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ tests/codeception/_output/*
tests/codeception/vendor/*
tests/codeception/testingsite*
tests/codeception/tests/acceptance.suite.yml
tests/codeception/tests/acceptance/*Tester.php
tests/codeception/tests/functional/*Tester.php
tests/codeception/tests/unit/*Tester.php

Expand Down
20 changes: 20 additions & 0 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,25 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop'])
->run()
->stopOnFail();

$this->taskCodecept($pathToCodeception)
->arg('--steps')
->arg('--debug')
->arg('--fail-fast')
->arg('--env ' . $opts['env'])
->arg('tests/acceptance/content.feature')
->run()
->stopOnFail();

$this->taskCodecept($pathToCodeception)
->arg('--steps')
->arg('--debug')
->arg('--fail-fast')
->arg('--env ' . $opts['env'])
->arg('tests/acceptance/users.feature')
->run()
->stopOnFail();

/*
$this->taskCodecept($pathToCodeception)
->arg('--steps')
->arg('--debug')
Expand All @@ -291,6 +310,7 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop'])
->run()
->stopOnFail();

*/
/*
// Uncomment this lines if you need to debug selenium errors
$seleniumErrors = file_get_contents('selenium.log');
Expand Down
147 changes: 141 additions & 6 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

{
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']);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not able to get configuration using $this>config and also not possible using below code,

$I->getConfiguration('window_size');

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

See https://github.com/joomla-projects/gsoc16_browser-automated-tests/blob/staging/tests/acceptance.suite.dist.yml#L16

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");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->debug and $->assertEquals methods are not working here, wondering how to make it working here.

Copy link
Member

Choose a reason for hiding this comment

The 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

modules:
    enabled:
        - JoomlaBrowser
        - AcceptanceHelper
        - Asserts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, Why do you want to Debug? you could use

$I->comment("Prital is doing a great job");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @puneet0191 I am using $I->debug() because the text should only display when --debug is set. I have seen that comment and debug belongs to same class type but debug is not working for some reason.

$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
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method iSeeArticleTrashMessage is similar to iSeeArticleUnpublishMessage:

/**
 * @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']);
}

}
39 changes: 29 additions & 10 deletions tests/_support/Page/Acceptance/Administrator/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,33 @@
class Login extends \AcceptanceTester
{
/**
* @When I login into Joomla Administrator with username :arg1 and password :arg1
*/
public function login($username, $password)
{
$I = $this;
$I->amOnPage('administrator/');
$I->fillField(['css' => 'input[data-tests="username"]'], $username);
$I->fillField(['css' => 'input[data-tests="password"]'], $password);
$I->click(['css' => 'button[data-tests="log in"]']);
}
* Install joomla CMS
*
* @Given Joomla CMS is installed
*/
public function joomlaCMSIsInstalled()
{
// throw new \Codeception\Exception\Incomplete("Step `Joomla CMS is installed` is not defined");
}

/**
* @When Login into Joomla administrator with username :arg1 and password :arg1
*/
public function loginIntoJoomlaAdministrator($username, $password)
{
$I = $this;
$I->amOnPage('administrator/');
$I->fillField(['css' => 'input[data-tests="username"]'], $username);
$I->fillField(['css' => 'input[data-tests="password"]'], $password);
$I->click(['css' => 'button[data-tests="log in"]']);
}

/**
* @Then I see administrator dashboard
*/
public function iSeeAdministratorDashboard()
{
$I = $this;
$I->waitForPageTitle('Control Panel', 4);
}
}
Loading