我想在大多数测试之前保留或运行登录。但是如果我尝试将登录代码移到_before,它就不能工作了,因为我没有可用的webguy实例。
在多个测试之间保持会话的最佳方式是什么?这是我的代码到目前为止,很高兴收到一些帮助。我在谷歌上搜索并检查了文档,但我找不到任何关于会话的东西。
<?php
use \WebGuy;
class ProductCest
{
private $product_id = '1';
public function _before()
{
}
public function _after()
{
}
// tests
public function login(WebGuy $I) {
$I->seeInCurrentUrl('/auth/login');
$I->fillField("//input[@type='email']", "username@email.com");
$I->fillField("//input[@type='password']", "1234");
$I->click('#signIn .submit');
$I->wait(500);
$I->seeInCurrentUrl('/account');
}
/**
* @depends login
*/
public function chooseProduct(WebGuy $I) {
$I->wantTo('go to products and choose one');
$I->amOnPage('/?product=' . $this->client_id);
}
}
https://stackoverflow.com/questions/20333240
复制相似问题