问题
I am going to make a test add article with behat in symfony but i should this error:
this is AjouterContext.php:
<?php
namespace test\MedBundle\Behat\Context;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\BehatContext;
use Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
use test\MedBundle\Entity\Apps;
use test\MedBundle\Entity\Product;
/**
* Defines application features from the specific context.
*/
class AjouterContext extends MinkContext
{
/**
* @When I press on :arg1
*/
public function iPressOn($arg1)
{
$element = $this->getSession()->getPage()->findById($arg1);
if (null === $element) {
var_dump('error');
}
$element->press();
}
/*
public function iClickOn2($arg1)
{
} */
/**
* @Then I wait :arg1 seconds
*/
public function iWaitSeconds($arg1)
{
$this->getSession()->wait($arg1 * 1000);
}
and this is ajouter.feature:
Feature: dossiertest
@javascript
Scenario: List 2 files in a directory
Given I am on the homepage
Then I should see "hello"
When I go to "/ajoutermed"
Then I should see "ajouter"
And I wait 2 seconds
And I fill in "test_medbundle_med_section" with "test section"
And I fill in "test_medbundle_med_info" with "test info"
And I press on "test_medbundle_med_submit"
Then I should see "ajouter"
this is behat.yml:
default:
suites:
default:
bundle: MedBundle
contexts:
- test\MedBundle\Behat\Context\FeatureContext
- test\MedBundle\Behat\Context\AjouterContext
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
base_url: http://localhost/test/web/app_dev.php
goutte: ~
javascript_session: selenium2
selenium2:
wd_host: http://localhost:4444/wd/hub
sessions:
default:
symfony2: ~
help me and thank you
来源:https://stackoverflow.com/questions/42911114/fatal-error-call-to-a-member-function-press-on-a-non-object