无法访问方案大纲示例的值

时间:2019-04-01 05:26:23

标签: php selenium behat gherkin

我正在尝试在步骤定义中访问我的方案大纲示例,但无法执行。

这是我的功能和方案...

功能:验证电子邮件 背景:假设我在“ https://www.somewebsite.com”上 方案大纲:确认电子邮件地址

鉴于我在电子邮件字段中填写“” 当我提交表格时 然后我应该看到“”

示例: | | | | |电子邮件为必填| |无效@ |电子邮件必须有效| | valid@gmail.com |成功页面|

这是我的步骤定义...

/**
 * @Given /^I fill in the email field with “(.*)”$/
 */
public function iFillInTheEmailFieldWith($email_value)
{
echo("email =====");
    echo($email_value);

}
  • 输出是打印标题名称。

而不是获取电子邮件的实际值(例如invalid @,valid @ gmail.com等),而是给我字面标题名称<email_value>

我在这里做错了什么?请帮助...

1 个答案:

答案 0 :(得分:0)

欢迎来到SO。在这里,我认为场景文件未正确写入此处。 下面是正确的方法。您必须使用诸如"<email_value>"之类的引号指定列名,才能在步骤def中访问该值。

Feature: verify email Background: Given I am on “https://www.somewebsite.com”

Scenario Outline: Confirm email address
Given I fill in the email field with "<email_value>"
When I submit the form Then I should see "<message>"

Examples:
  | email_value     | message             |
  |                 | email is required   |
  | invalid@        | email must be valid |
  | valid@gmail.com | success page        |