2016-09-23 2 views
0

Das erste Szenario läuft funktioniert, aber die zweite nichtFehler beim Behat

Die Funktion Datei:

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 "[email protected]" 

die 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); 
    } 

Die Fehlermeldung:

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 "[email protected]"      # FeatureContext::fillField() 
     Form field with id|name|label|value|placeholder "Email" not found. (Behat\Mink\Exception\ElementNotFoundException) 
    And I click the "#next" element 

Und wenn beide Szenarien laufen d wenn es dann funktioniert, funktioniert es einwandfrei. Warum es nicht funktioniert, wenn beide Szenarien zusammen kombiniert werden.

Antwort

1

Sie sollten @insulated Tag auf Feature-Ebene verwenden.
Dieses Tag sorgt dafür, dass Sie jedes Mal eine saubere Sitzung haben.

Fügen Sie dieses Tag in die erste Zeile Ihrer Feature-Datei ein, bevor Sie den Schlüssel Feature eingeben.

Sie @javascript die gleiche Weise bei einer Leistungsstufe verwenden können, und es wird für jedes Szenario

+0

Sie gelten danken es funktionieren. –

+0

Gern geschehen :) – lauda

+0

Gibt es eine Möglichkeit, einen bestimmten Text aus Google Mail zu kopieren und in meinem nächsten Szenario zu verwenden? –