我正在尝试通过运行以下功能方案在Chrome浏览器中运行behat / selenium,并且我想要保留浏览器屏幕而不立即关闭Chrome浏览器。我在执行步骤定义iWaitForSeconds时遇到以下错误,但我已经这样做了。以下是所有代码,请你帮忙看看我做错了什么?非常感谢!!!!
2 scenarios (2 undefined)
10 steps (8 passed, 2 undefined)
0m3.896s
You can implement step definitions for undefined steps with these snippets:
/**
* @Given /^I wait for "([^"]*)" seconds$/
*/
public function iWaitForSeconds($arg1)
{
throw new PendingException();
}
/behat_sample/features/search.feature
# features/search.feature
Feature: Search
In order to see a word definition
As a website user
I need to be able to search for a word
@javascript
Scenario: Searching for a page that does exist
Given I am on "/wiki/Main_Page"
When I fill in "search" with "Behavior Driven Development"
And I press "searchButton"
Then I should see "agile software development"
And I wait for "60" seconds
/behat_sample/behat.yml
#behat.yml
default:
paths:
features: features
bootstrap: '/behat_sample/features/bootstrap'
extensions:
Behat\MinkExtension\Extension:
base_url: 'http://en.wikipedia.org/'
goutte: ~
selenium2: ~
browser_name: chrome
/behat_sample/features/bootstrap/FeatureContext.php
namespace bootstrap;
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
/**
* Features context.
*/
class FeatureContext extends MinkContext
{
/**
* Initializes context.
* Every scenario gets it's own context object.
*
* @param array $parameters context parameters (set them up through behat.yml)
*/
public function __construct(array $parameters)
{
// Initialize your context here
}
/**
* @Given /^I wait for (\d+) seconds$/
*/
public function iWaitForSeconds($seconds)
{
$this->getSession()->wait($seconds*1000);
throw new PendingException();
}
答案 0 :(得分:0)
好像你在bulkInsert
配置密钥中设置了错误的路径。
它会查找bootstrap
而不是/behat_sample/features/bootstrap
尝试以下方法:
your_current_base_behat_dir/features/bootstrap
其中bootstrap: '%paths.base%/features/bootstrap'
- 那就是根目录所在的位置,从哪里开始运行behat
答案 1 :(得分:0)
正如我在代码中看到的那样,您需要从throw new PendingException()
步骤实施中移除/^I wait for (\d+) seconds$/
。
如果等待完成,那么它应该继续不抛出异常。