Sunday, October 26, 2014

Codeception Helpers

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.

Related Posts:

  • Codeception:Variables for UI Elements As we know we can write complex tests using codeception.Think of a scenario of a login page. We have generally 3 fields in login page. 1.User id fiels 2.Password field 3.Sign in button. We have created a test using codecep… Read More
  • Codeception Helpers 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… Read More
  • Creation Of Cest Ever wanted a structure as classes for your Cepts! Then Cest format should be your choice. The biggest advantage is that it is very simple and compatibility with Cept scenarios. So if your script/test is bit lengthy and you … Read More
  • Repopulation of database using mysql instead of db module What is DB module: The DB module is used to cleaning database before each test. So this module was added into codeception.yml. To have your database properly cleaned you should configure it to access the database. Also pro… Read More
  • Codeception Modules In Codception various modules are comes as packages initially. Some of them are Webdriver,symphony,Laravel etc. Modules allow you to choose the actions and assertions that can be performed in tests. All actions and assertion… Read More

0 comments:

Post a Comment

Powered by Blogger.