我一直在努力解决这个问题3个小时,并且似乎无法理解为什么这不起作用。我的selenium服务器启动正常。
当我使用selenium运行behat时,我的终端上出现以下错误
Fatal error: Call to a member function open() on null (Behat\Testwork\Call\Exception\FatalThrowableError)
我不知道此错误消息的含义。如果有人能帮我解决这个问题,我会非常感激。
以下是我发现问题的功能上下文代码
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Mink\Driver\Selenium2Driver;
/**
* Defines application features from the specific context.
*/
class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext
{
public $session;
public function __construct()
{
$driver = new \Behat\Mink\Driver\Selenium2Driver('firefox');
$this->session = new \Behat\Mink\Session($driver);
}
}
答案 0 :(得分:0)
执行以下操作:
ON DELETE CASCADE
示例behat.yml
class FeatureContext extends MinkContext
{
public function __construct()
{
// Don't do anything with session or driver here
}
/**
* @Then /^I need selenium driver for this step$/
*/
public function iNeedSeleniumDriverForThisStep()
{
$driver = $this->getSession()->getDriver();
if (!$driver instanceof Selenium2Driver) {
throw new UnsupportedDriverActionException('Selenium2Driver not installed.');
return;
}
// ......
// ......
// Do whatever you want
}
}
同时在此网站中搜索default:
context:
class: FeatureContext
extensions:
Behat\Symfony2Extension\Extension:
mink_driver: true
kernel:
env: test
debug: true
Behat\MinkExtension\Extension:
base_url: 'http://symfony.local/app_test.php/'
files_path: %behat.paths.base%/build/dummy/
javascript_session: selenium2
browser_name: firefox
goutte: ~
selenium2: ~
paths:
features: %behat.paths.base%/src
bootstrap: %behat.paths.features%/Context
和Selenium2Driver
个关键字:http://www.inanzzz.com/index.php/posts/behat