|
17 | 17 | package org.openqa.selenium;
|
18 | 18 |
|
19 | 19 | import com.google.common.annotations.VisibleForTesting;
|
20 |
| -import com.google.common.base.Optional; |
21 | 20 | import com.google.common.base.Supplier;
|
22 | 21 | import com.google.common.collect.Maps;
|
23 | 22 |
|
|
35 | 34 | */
|
36 | 35 | public class WebDriverCommandProcessor implements CommandProcessor, WrapsDriver {
|
37 | 36 |
|
38 |
| - /** |
39 |
| - * Capability key that dictates whether to emulate Selenium's alert handling and override |
40 |
| - * the native alert functions. Defaults to true. |
41 |
| - */ |
42 |
| - public static final String ENABLE_ALERT_OVERRIDES_CAPABILITY = |
43 |
| - "selenium.emulation.overrideAlerts"; |
44 |
| - |
45 | 37 | private final Map<String, SeleneseCommand<?>> seleneseMethods = Maps.newHashMap();
|
46 | 38 | private final String baseUrl;
|
47 | 39 | private final Timer timer;
|
48 | 40 | private final CompoundMutator scriptMutator;
|
| 41 | + private boolean enableAlertOverrides = true; |
49 | 42 | private Supplier<WebDriver> maker;
|
50 | 43 | private WebDriver driver;
|
51 | 44 |
|
@@ -179,22 +172,21 @@ protected void assertDriverSupportsJavascript(WebDriver driver) {
|
179 | 172 | }
|
180 | 173 | }
|
181 | 174 |
|
182 |
| - private boolean enableOverrides() { |
183 |
| - Optional<Boolean> enableOverrides = Optional.absent(); |
184 |
| - if (driver instanceof HasCapabilities) { |
185 |
| - Object tmp = ((HasCapabilities) driver).getCapabilities().getCapability( |
186 |
| - ENABLE_ALERT_OVERRIDES_CAPABILITY); |
187 |
| - enableOverrides = Optional.fromNullable((Boolean) tmp); |
188 |
| - } |
189 |
| - return enableOverrides.or(true); // Default to true if capability wasn't specified. |
| 175 | + /** |
| 176 | + * Sets whether to enable emulation of Selenium's alert handling functions or |
| 177 | + * to preserve WebDriver's alert handling. This has no affect after calling |
| 178 | + * {@link #start()}. |
| 179 | + */ |
| 180 | + public void setEnableAlertOverrides(boolean enableAlertOverrides) { |
| 181 | + this.enableAlertOverrides = enableAlertOverrides; |
190 | 182 | }
|
191 | 183 |
|
192 | 184 | private void setUpMethodMap() {
|
193 | 185 | JavascriptLibrary javascriptLibrary = new JavascriptLibrary();
|
194 | 186 | ElementFinder elementFinder = new ElementFinder(javascriptLibrary);
|
195 | 187 | KeyState keyState = new KeyState();
|
196 | 188 |
|
197 |
| - AlertOverride alertOverride = new AlertOverride(enableOverrides()); |
| 189 | + AlertOverride alertOverride = new AlertOverride(enableAlertOverrides); |
198 | 190 | Windows windows = new Windows(driver);
|
199 | 191 |
|
200 | 192 | // Note the we use the names used by the CommandProcessor
|
|
0 commit comments