SELENIUM-260: support fluent syntax for setting rule properties instead of using constructor parameters

Merged
#21 · Created  · Last updated

Merged pull request

Merged in issue/SELENIUM-260-rule-config (pull request #21)

3720241·Author: ·Closed by: ·2015-03-04

Description

This is an attempt at a cleaner way of declaring rules that have overridable properties with default values.

Most of our rules have several constructor overloads to support different ways of specifying the driver instance; I've retained those, since I'd imagine we don't want to call WebDriverSupport.fromAutoInstall(), for instance, if we don't have to. For additional properties which we were providing as parameters in overloaded constructors, I added chainable methods for constructing a new instance based on the current one but with one property changed. For instance, you can now declare a JavaScriptErrorsRule like this:

@ClassRule public static JavaScriptErrorsRule jser = new JavaScriptErrorsRule() .errorsToIgnore(ImmutableSet.of("foo", "bar")) .failOnJavaScriptErrors(true);

I retained the existing constructor overloads for backward compatibility, except in the case of JavaScriptErrorsRule since it hasn't appeared in any non-milestone release yet.

I also refactored JavaScriptErrorsRule quite a bit so that everything we might want to override in it, including the underlying "how to get the errors" logic, can now be done without subclassing— the new property chaining pattern requires that the property methods all return the same class, but I think this is preferable anyway.

0 attachments

0 comments

Loading commits...