I currently have a problem with Java and Cucumber. Accessing a website's element by using Selenium, I want to use phrases like the following:

Then the value of the attribute XYZ should be 1000

That example is quite trivial and works fine for each attribute name by using the Java annotation

@Then("the value of the attribute (.*) should be (.*)")

except for the following use-case: an attribute name contains parentheses like ABC(s).

While using Eclipse and JUnit, a Cucumber test with a string containing parentheses like that is not even recognized completely but just the part of the string before the opening bracket. Any ideas or solutions?

有帮助吗?

解决方案

It doesn't matter whether the attribute name contains any parentheses.

When using this method:

@Then("^the value of the attribute (.*) should be (.*)$")
public void checkAttributeValue(String name, String value)
        throws Throwable {
    System.out.println("Name: " + name + " value: " + value);
}

And

Then the value of the attribute XYZ(s) should be 1000

I get

Name: XYZ(s) value: 1000

Which I think is what you expect.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top