ds20021205 2016-09-23 13:06
浏览 23
已采纳

运行behat时出错

The first scenario works but the second one fails

The feature file:

And I click the "#redeem" element
And I wait for the ajax response
And I should see "OPERATOR CONTACT DETAILS AND INFORMATION WILL BE PROVIDED VIA EMAIL ON CONFIRMATION"
And I click the "#place_order" element
And I wait for the ajax response
Then I should see "Woohoo and thanks for booking!"

@javascript
Scenario: For checking mail in inbox of Gmail 
Given I am on "https://gmail.com"
And I wait 12 seconds
And I fill in "Email" with "amit.dinda.prdxn@gmail.com"

the minkcontext:

/**
     * Fills in form field with specified id|name|label|value.
     *
     * @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/
     * @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with:$/
     * @When /^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/
     */
    public function fillField($field, $value)
    {
        $field = $this->fixStepArgument($field);
        $value = $this->fixStepArgument($value);
        $this->getSession()->getPage()->fillField($field, $value);
    }

The error message :

 And I should see "OPERATOR CONTACT DETAILS AND INFORMATION WILL BE PROVIDED VIA EMAIL ON CONFIRMATION" # FeatureContext::assertPageContainsText()
    And I click the "#place_order" element                                                                 # FeatureContext::iClickTheElement()
    And I wait for the ajax response                                                                       # FeatureContext::iWaitForTheAjaxResponse()
    Then I should see "Woohoo and thanks for booking!"                                                     # FeatureContext::assertPageContainsText()

  @javascript
  Scenario: For checking mail in inbox of Gmail                                 # features/Redeem_a_Experience_voucher.feature:45
    Given I am on "https://gmail.com"                                           # FeatureContext::visit()
    And I wait 12 seconds                                                       # FeatureContext::iWaitSeconds()
    And I fill in "Email" with "amit.dinda.prdxn@gmail.com"                     # FeatureContext::fillField()
      Form field with id|name|label|value|placeholder "Email" not found. (Behat\Mink\Exception\ElementNotFoundException)
    And I click the "#next" element   

And if run both scenario differently then it works porperly. Why it not work if both scenario are combined together.

  • 写回答

1条回答 默认 最新

  • douhunkuang8955 2016-09-23 13:22
    关注

    You should use @insulated tag at the Feature level.
    This tag will make sure that you will have a clean session each time.

    Add this tag on the first line of your feature file, before Feature key.

    You can use @javascript the same way at a feature level and it will apply for each scenario

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号