Skip to content

Commit

Permalink
Firefox: Implementing a capability that disables overlapping checks
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Feb 9, 2016
1 parent 7d06243 commit ab99406
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
Expand Up @@ -41,6 +41,7 @@ public interface CapabilityType {
String UNEXPECTED_ALERT_BEHAVIOUR = "unexpectedAlertBehaviour";
String ELEMENT_SCROLL_BEHAVIOR = "elementScrollBehavior";
String HAS_TOUCHSCREEN = "hasTouchScreen";
String OVERLAPPING_CHECK_DISABLED = "overlappingCheckDisabled";

String LOGGING_PREFS = "loggingPrefs";

Expand Down
Expand Up @@ -48,6 +48,8 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.environment.GlobalTestEnvironment;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.UnreachableBrowserException;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
Expand Down Expand Up @@ -582,6 +584,29 @@ public void searchingByCssDoesNotOverwriteExistingSizzleDefinition() {
((JavascriptExecutor) driver).executeScript("return window.Sizzle + '';"));
}

@Test
public void testFirefoxCanNativelyClickOverlappingElements() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.OVERLAPPING_CHECK_DISABLED, true);
WebDriver secondDriver = new FirefoxDriver(capabilities);
try {
secondDriver.get(appServer.whereIs("click_tests/overlapping_elements.html"));
secondDriver.findElement(By.id("under")).click();
assertEquals(secondDriver.findElement(By.id("log")).getText(),
"Log:\n"
+ "mousedown in over (handled by over)\n"
+ "mousedown in over (handled by body)\n"
+ "mouseup in over (handled by over)\n"
+ "mouseup in over (handled by body)\n"
+ "click in over (handled by over)\n"
+ "click in over (handled by body)");
} finally {
secondDriver.quit();
}
}



private WebDriver newFirefoxDriver() {
return newFirefoxDriver(new FirefoxProfile());
}
Expand Down
1 change: 1 addition & 0 deletions javascript/firefox-driver/js/sessionstore.js
Expand Up @@ -167,6 +167,7 @@ wdSessionStoreService.CAPABILITY_PREFERENCE_MAPPING = {
'applicationCacheEnabled': 'browser.cache.offline.enable',
'databaseEnabled': 'dom.indexedDB.enabled',
'elementScrollBehavior' : 'webdriver.elementScrollBehavior',
'overlappingCheckDisabled' : 'webdriver.overlappingCheckDisabled',
'locationContextEnabled': 'geo.enabled',
'browserConnectionEnabled': 'dom.network.enabled',
'acceptSslCerts': 'webdriver_accept_untrusted_certs',
Expand Down
17 changes: 14 additions & 3 deletions javascript/firefox-driver/js/syntheticMouse.js
Expand Up @@ -83,9 +83,20 @@ SyntheticMouse.prototype.isElementShownAndClickable = function(element) {
return error;
}

var error = this.isElementClickable(element);
if (error) {
return error;
var checkOverlapping = true;
try {
var prefStore = fxdriver.moz.getService('@mozilla.org/preferences-service;1',
'nsIPrefBranch');
if (prefStore.getBoolPref('webdriver.overlappingCheckDisabled', false)) {
checkOverlapping = false;
}
} catch (ignored) {}

if (checkOverlapping) {
error = this.isElementClickable(element);
if (error) {
return error;
}
}
}

Expand Down

0 comments on commit ab99406

Please sign in to comment.