when I use the AcceptanceHelper generated by codeception (_support/AcceptanceHelper.php), how can I access the Actor / AcceptanceTester ($I). And how can I access my functions from StepObjects?
I have:
acceptance/_steps/MyStepObject.php
namespace AcceptanceTester;
class MyStepObject extends \AcceptanceTester
{
public function deleteCookies(){
$I = $this;
$I->amGoingTo("delete all cookies...");
$I->executeInSelenium(function(\WebDriver $webdriver) {$webdriver->manage()->deleteAllCookies(); });
$I->reloadPage();
}
public function loginUser($user,$password,$language = 'Untranslated')
{
$I = $this;
$I->amOnPage(\LoginPage::$URL);
$I->deleteCookies();
$I->amGoingTo('fill the fields...');
$I->fillField(\LoginPage::$usernameField, $user);
$I->fillField(\LoginPage::$passwordField, $password);
$I->click(\LoginPage::$loginButton);
}
}
In the class _support/AcceptanceHelper.php
I want to call methods from the AcceptanceTester like $I->canSee('something')
and I want to call my own methods (like 'login'
) from my StepObject.
I know I can get a specific module (e.g. the WebDriver) with $this->getModule('WebDriver')
. But how can I get the AcceptanceTester / my StepObject?
Yii Framework provides basic and advanced application templates. Both include sample Codeception tests, thus to start with Codeception you need to start new Yii project from a one of those templates.
assertGreaterThanOrEqual. Asserts that a value is greater than or equal to another value.
Passing in the $I variable from the test. It's a bit verbose but works fine.
public function deleteCookies($I){...}
and then in tests write:
$I->deleteCookies($I);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With