Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top