简体   繁体   English

在黄瓜步骤定义上传递多个参数

[英]Passing multiple arguments on Cucumber step definition

I have cucumber step like this 我有这样的黄瓜步骤

Given I am on (Similar Article Alerts|Search Alerts|Journal Alerts) page

I have a step definition for this 我对此有一个步骤定义

  @Given("^I am on \"([^\"]*)\" page$")
   public void iAmOnSimilar_X_Page(String pageName) throws Throwable {
  // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
   }

but I am getting Undefined step reference. 但我得到未定义的步骤参考。 Could anyone help me with this please? 有人可以帮我吗?

you have to escape the opening and closing parenthesis \\( and \\) instead of double quotes, they are not present in your example data. 您必须转义括号\\(\\)而不是双引号,因为它们不在示例数据中。

In the negating character class match not a closing parenthesis [^)]+ 在否定字符类匹配中,不包含右括号[^)]+

^I am on \\(([^)]*)\\) page$

In Java: 在Java中:

String regex = "^I am on \\(([^)]*)\\) page$";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM