i have a Yii2 project and i'm running automated tests with Codeception.
I intend to get a reference to the Webdriver instance. How to do that?
I am getting an undefined method exception when i call $this->getModule("WebDriver") from the Cest class or the Acceptancetester class.
This is my acceptance.suite.yml file:
class_name: AcceptanceTester
modules:
enabled:
- Cli:
- WebDriver:
url: http://localhost:8081/
browser: firefox
port: 4455
- Yii2:
part: [orm,fixtures]
entryScript: index-test.php
cleanup: false
And this is my AcceptanceTester that is trying to reference the WebDriver:
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
public function sendEnterKey(){
// the following line will raise an exception
$driver = $this->getModule("WebDriver");
$driver->getKeyboard()->sendKeys(\Facebook\WebDriver\WebDriverKeys::ENTER);
}
}
I am getting an exception saying " Call to undefined method AcceptanceTester::getModule" when calling the AcceptanceTester::sendEnterKey method
p.s. There is another question with the same title: Call to undefined method AcceptanceTester::getModule, but this is not a duplicate. The problem in that question was due to the getModule call being in the Cest class. But i did not make the same mistake. I put the call in the AcceptanceTester