如何访问behat场景大纲的示例值?

问题描述 投票:0回答:1

这应该是简单而直接的事情,但我无法在网上找到答案。在Behat中使用场景大纲时,如何在测试中访问示例值?对于以下示例,我将如何在测试中访问电子邮件地址?我的自动化测试基本上会填写一个带有电子邮件地址的文本字段,所以我想知道如何用正在运行的特定方案使用的email_value填充它?

Feature: Email validation
Background: Given I am on “www.somewebsite.com”
Scenario Outline: Confirm email validation

Given I fill in the email field with “”
When I submit the form
Then I should see “”

**Examples:**
|      |  |
|                   | A validation message that email is required|
| steve@            | A validation message that email must be valid |
| [email protected]   | The review page |

这是我的测试用例调用的函数,它只是找到文本字段并填写电子邮件地址...而不是填写“测试”,我想用我的大纲中的email_value填写它。如何从我的函数中访问该值?

public function fillForm()
    {
         $element = $this->driver->findElement($this->emailTextField);
         $element->click();
         $element->sendKeys("testing");

         #Please review your response and confirm.
    }

2)有些相关的第二个问题是我想检查submission_result以查看它是否包含“验证消息”这个词然后我知道它是一个成功的(例如有效的)电子邮件,并将带我到一个成功页面而不是显示错误。

多谢你们!

php bdd behat
1个回答
0
投票

这些是开箱即用的定义步骤,你需要检查你是否拥有所需的一切,如果不是,你需要自己定义它们。

至于不同类型的参数

例: I fill in "field" for "value"

字段和字段作为参数传递给关联的方法,因此如果要打印它们或将其记录在某处,则需要访问该方法。

对于场景大纲:

  Scenario Outline:
    Given I fill in "" with "value_placeholder"

    Examples:
      | field_placeholder | value_placeholder |
      | field_identifier  | actual_value      |

使用支持Behat和ctrl / command的编辑器+单击步骤并查看如何使用它们。

© www.soinside.com 2019 - 2024. All rights reserved.