You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time when I call open(url) in my tests, I want to add a proxy filter.
But Selenide doesn't allow adding multiple filters with the same name.
So I need to add an IF like this:
open();
if (getSelenideProxy().requestFilter("request-logger") == null) {
getSelenideProxy().addRequestFilter("request-logger", MY_LOGGER);
}
Solution
Method addRequestFilter could silently ignore without throwing an error IF the filter is exactly the same instance as previously.
Then I could safely add getSelenideProxy().addRequestFilter("request-logger", MY_CONSTANT_LOGGER); all over my tests.
The text was updated successfully, but these errors were encountered:
it's convenient to store a filter into a constant, and add it before every `open(url)` - without checking if it was already added earlier.
```
var MY_CONSTANT_LOGGER = new RequestFilter() {...}
getSelenideProxy().addRequestFilter("request-logger", MY_CONSTANT_LOGGER);
```
it's convenient to store a filter into a constant, and add it before every `open(url)` - without checking if it was already added earlier.
```
var MY_CONSTANT_LOGGER = new RequestFilter() {...}
getSelenideProxy().addRequestFilter("request-logger", MY_CONSTANT_LOGGER);
```
The problem
Every time when I call
open(url)
in my tests, I want to add a proxy filter.But Selenide doesn't allow adding multiple filters with the same name.
So I need to add an IF like this:
Solution
Method
addRequestFilter
could silently ignore without throwing an error IF the filter is exactly the same instance as previously.Then I could safely add
getSelenideProxy().addRequestFilter("request-logger", MY_CONSTANT_LOGGER);
all over my tests.The text was updated successfully, but these errors were encountered: