Modules
- Modules play an important role in Codeception framework and helps :
- The target user by giving a key to define their own categorize their modules/functionality
- Defining Folder Structure
- Specifying module specific helper method
- Modules are php file which is always stored under <Project Home> : <Name of module.php> eg : CC_90_ActionsHelper.php
-
Modules can
be turned on/off from acceptance.suite.yml
class_name: AcceptanceTester modules: enabled: - WebDriver - AcceptanceHelper - CC_90_ActionsHelper config: WebDriver: url: 'xxx' browser: chrome window_size: 1124x850 wait: 10 delay: 2 capabilities: unexpectedAlertBehaviour: 'accept'
-
Modules are
always inherited from \Codeception\Module class, hence
structure looks like below:
<?php class CC_90_ActionsHelper extends \Codeception\Module{ ........ }
Helpers
- Helpers are custom actions which are created to reuse them multiple of times in the test
-
Helpers
are always created in modules (/support
/* * Login to customercare * * Example: - * * $I->loginToCC(&I, 'AlliedBuilding', 'btbt', btbt); * * * @param String $customername : Name of the Customer * @param String $userName : User Name * @param String $password : Password * */ public function loginToCC($I, $custName, $userName, $password){ $I->fillField(['xpath' => Locators::$cc_custName], $custName); $I->fillField(['xpath' => Locators::$cc_userName], $userName); $I->fillField(['xpath' => Locators::$cc_password], $password); $I->click(['xpath' => Locators::$cc_signIn]); return $this; }
-
Build command is used to add the helper method to acceptancetester.phpCommand : [php codecept.phar build]
- Once method added, it can be used in the tests as usual.