How can I access an actor (e.g. AcceptanceTester) in the Codeception Helper

when I use the AcceptanceHelper generated by code generation (_support / AcceptanceHelper.php), how can I access the Actor / AcceptanceTester test ($ I). And how can I access my functions from StepObjects?

I have:

reception /_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 _support/AcceptanceHelper.php class, I want to call methods from AcceptanceTester, for example $I->canSee('something') , and I want to call my own methods (e.g. 'login' ) from my StepObject.

I know that I can get a specific module (e.g. WebDriver) using $this->getModule('WebDriver') . But how can I get AcceptanceTester / my StepObject?

+5
source share
1 answer

Passing the variable $ I from the test. This is a bit verbose, but works great.

public function deleteCookies($I){...}

and then in the tests write:

$I->deleteCookies($I);

+1
source

Source: https://habr.com/ru/post/1203864/


All Articles