首页 > 解决方案 > 无法访问场景大纲示例的值

问题描述

我试图在我的步骤定义中访问我的场景大纲示例,但我无法访问。

这是我的特点和场景......

功能:验证电子邮件背景:鉴于我在“<a href="https://www.somewebsite.com" rel="nofollow noreferrer">https://www.somewebsite.com” 场景大纲:确认电子邮件地址

鉴于我在电子邮件字段中填写了“”当我提交表单时,我应该会看到“”</p>

示例:| | | | | 电子邮件是必需的| | 无效@ | 电子邮件必须有效 | | 有效@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>

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

标签: phpseleniumbehatgherkin

解决方案


欢迎来到 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        |

推荐阅读