Codeception has always the flexibilty to add the add the custom actions to the test suite.
It just doesn't restrict to add custom actions.
'bootstrap' is the command to that codeception generates these modules.
These modules actually called the Helpers.
These Helper files are always created in tests/support.
So here every action defined is a public function.
So we need to run a build 'build' command.
Once after running build command you will see the function is getting added to AcceptanceTester class.
Lets take an example of login helper class.
/*
* Login to My Site
*
* Example: -
*
* $I->MyLogin(&I, 'test', 'testuser', 'testpassword');
*
*
* @param String $customername: Name of the Customer
* @param String $userName : User Name
* @param String $password : Password
*
*/
public function MyLogin($I, $username, $password){
$I->amOnPage('/');
$I->click('Login');
$I->fillField('signin_username',$username);
$I->fillField('signin_password',$password);
$I->click('signin_signin');
$I->seeInCurrentUrl("home");
$I->see("My Home Page");
So if you ever need to use the login multiple time in your script you don't need to write these steps.You just need to call the helper function.
It just doesn't restrict to add custom actions.
'bootstrap' is the command to that codeception generates these modules.
These modules actually called the Helpers.
These Helper files are always created in tests/support.
So here every action defined is a public function.
So we need to run a build 'build' command.
Once after running build command you will see the function is getting added to AcceptanceTester class.
Lets take an example of login helper class.
/*
* Login to My Site
*
* Example: -
*
* $I->MyLogin(&I, 'test', 'testuser', 'testpassword');
*
*
* @param String $customername: Name of the Customer
* @param String $userName : User Name
* @param String $password : Password
*
*/
public function MyLogin($I, $username, $password){
$I->amOnPage('/');
$I->click('Login');
$I->fillField('signin_username',$username);
$I->fillField('signin_password',$password);
$I->click('signin_signin');
$I->seeInCurrentUrl("home");
$I->see("My Home Page");
So if you ever need to use the login multiple time in your script you don't need to write these steps.You just need to call the helper function.
0 comments:
Post a Comment