|
30 | 30 | import java.util.Set;
|
31 | 31 | import java.util.function.BiFunction;
|
32 | 32 | import java.util.function.Predicate;
|
| 33 | +import java.util.logging.Logger; |
33 | 34 | import java.util.stream.Collectors;
|
34 | 35 | import java.util.stream.Stream;
|
35 | 36 | import java.util.stream.StreamSupport;
|
|
59 | 60 | */
|
60 | 61 | @Beta
|
61 | 62 | public class Augmenter {
|
| 63 | + |
| 64 | + private static final Logger LOG = Logger.getLogger(Augmenter.class.getName()); |
62 | 65 | private final Set<Augmentation<?>> augmentations;
|
63 | 66 |
|
64 | 67 | public Augmenter() {
|
@@ -147,6 +150,19 @@ public WebDriver augment(WebDriver driver) {
|
147 | 150 | Require.precondition(
|
148 | 151 | driver instanceof HasCapabilities, "Driver must have capabilities", driver);
|
149 | 152 |
|
| 153 | + if (driver instanceof Decorated<?>) { |
| 154 | + LOG.warning( |
| 155 | + "Warning: In future versions, passing a decorated driver will no longer be allowed.\n" |
| 156 | + + " Instead, augment the driver first and then use it to created a decorated" |
| 157 | + + " driver.\n" |
| 158 | + + " Explanation: Decorated drivers are not aware of the augmentations applied to" |
| 159 | + + " them. It can lead to expected behavior.\n" |
| 160 | + + " For example, augmenting HasDevTools interface to a decorated driver. \n" |
| 161 | + + " The decorated driver is not aware that after augmentation it is an instance of" |
| 162 | + + " HasDevTools. So it does not invoke the close() method of the underlying" |
| 163 | + + " websocket, potentially causing a memory leak. "); |
| 164 | + } |
| 165 | + |
150 | 166 | Capabilities caps = ImmutableCapabilities.copyOf(((HasCapabilities) driver).getCapabilities());
|
151 | 167 |
|
152 | 168 | // Collect the interfaces to apply
|
|
0 commit comments