Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在步骤定义上传递多个参数_Java_Regex_Automation_Cucumber - Fatal编程技术网

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

Java 在步骤定义上传递多个参数,java,regex,automation,cucumber,Java,Regex,Automation,Cucumber,我有像这样的黄瓜步 Given I am on (Similar Article Alerts|Search Alerts|Journal Alerts) page 我对此有一个步骤定义 @Given("^I am on \"([^\"]*)\" page$") public void iAmOnSimilar_X_Page(String pageName) throws Throwable { // Write code here that turns the phrase a

我有像这样的黄瓜步

Given I am on (Similar Article Alerts|Search Alerts|Journal Alerts) page
我对此有一个步骤定义

  @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();
   }
但我得到的是未定义的步进参考。
有人能帮我吗

您必须转义开始和结束括号
\(
\)
,而不是双引号,它们不在示例数据中

在求反字符类中,不匹配右括号
[^)]+

在Java中:

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

这里没有引号,对吗?如果需要作为
pageName
传递的文本位于括号之间,请尝试
@Given(“^I在”(.*)page$”
)。删除
\(
\)
,如果在上的
页面
之间有任何文本。