I'm building acceptance tests in codeception for a Yii2 based web app. The Yii2 GridView offers a set of action buttons which can be selected for click with an Xpath selector in the form of
$I->click('', '//a[@href[contains(.,"view&id=97")]]');
This works fine, until I want to click 'delete' which comes back with an error saying that the method requires a POST (which is of course correct).
Having realized that I have no idea how to intercept the Javascript popup which will ask me if I really want to delete this, I though of another approach.
The idea was to extract the link info from the element and POST the data directly to this link. This requires the _request method which can only be used in helpers, so I made a helper. I cannot get the helper class working, because if use _findElements to locate the button it tells me that the crawler is null, and if I try to get round this by loading a page in the helper I get an error. Specifically the code
class Acceptance extends \Codeception\Module
{
public function clickActionButton($page)
{
$module = $this->getModule('Yii2');
$module->_loadPage('GET', $page);
}
}
gives the error '[yii\base\InvalidConfigException] The directory does not exist: ./vendor/bin/assets' (It also reports an error while trying to handle this error, but that's for later)
I have no idea why this is happening. My config file looks like
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://localhost:8000
- Yii2:
configFile : '/config/web.php'
part: ORM
- \Helper\Acceptance
And as recommend in this article Codeception not found Yii I've added the following to the _bootstrap.php for acceptance
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
$config = require(__DIR__ . '/../config/console.php');
//
$application = new yii\console\Application( $config );
(It also reports an error while trying to handle this error, but that's for later)
No doubt I've missed something simple, but I'm fairly new to Yii and can't work it out. (It also reports an error while trying to handle this error, but that's for later)