Skip to content

Commit

Permalink
[java] Deleting all Sauce related guards in tests
Browse files Browse the repository at this point in the history
Even if we decide to get back to Sauce in future all these guards are out of date.
  • Loading branch information
barancev committed Oct 25, 2018
1 parent 0c37f50 commit 2613fc3
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.NotYetImplemented;
import org.openqa.selenium.testing.TestUtilities;
import org.openqa.selenium.testing.drivers.SauceDriver;
import org.openqa.selenium.testing.drivers.WebDriverBuilder;

import java.io.File;
Expand Down Expand Up @@ -443,9 +442,6 @@ private String getTextFromElementOnceAvailable(String elementId) {

@Test
public void testShouldReportTheXAndYCoordinatesWhenClicking() {
assumeFalse("Skipping test which fails in IE on Sauce",
SauceDriver.shouldUseSauce() && TestUtilities.isInternetExplorer(driver));

driver.get(pages.clickEventPage);

WebElement element = driver.findElement(By.id("eventish"));
Expand Down
3 changes: 0 additions & 3 deletions java/client/test/org/openqa/selenium/PageLoadingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import static org.openqa.selenium.testing.Driver.IE;
import static org.openqa.selenium.testing.Driver.MARIONETTE;
import static org.openqa.selenium.testing.Driver.SAFARI;
import static org.openqa.selenium.testing.drivers.SauceDriver.shouldUseSauce;

import org.junit.After;
import org.junit.Test;
Expand Down Expand Up @@ -199,15 +198,13 @@ public void testShouldReturnWhenGettingAUrlThatDoesNotResolve() {
@NeedsFreshDriver(value = FIREFOX, reason = "No idea why it throws in a fresh driver only")
@Test
public void testShouldThrowIfUrlIsMalformed() {
assumeFalse("Fails in Sauce Cloud", shouldUseSauce());
assertThatExceptionOfType(WebDriverException.class)
.isThrownBy(() -> driver.get("www.test.com"));
}

@Test
@NotYetImplemented(value = SAFARI)
public void testShouldThrowIfUrlIsMalformedInPortPart() {
assumeFalse("Fails in Sauce Cloud", shouldUseSauce());
assertThatExceptionOfType(WebDriverException.class)
.isThrownBy(() -> driver.get("http://localhost:3001bla"));
}
Expand Down
13 changes: 0 additions & 13 deletions java/client/test/org/openqa/selenium/TakesScreenshotTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.NotYetImplemented;
import org.openqa.selenium.testing.SwitchToTopAfterTest;
import org.openqa.selenium.testing.drivers.SauceDriver;

import java.awt.image.BufferedImage;
import java.awt.image.Raster;
Expand Down Expand Up @@ -120,10 +119,6 @@ public void testGetScreenshotAsBinary() {

@Test
public void testShouldCaptureScreenshotOfCurrentViewport() {
// Fails on Sauce for whatever reason; probably display or window manager.
assumeFalse(SauceDriver.shouldUseSauce()
&& getEffectivePlatform(driver).is(LINUX)
&& isChrome(driver));
driver.get(appServer.whereIs("screen/screen.html"));

BufferedImage screenshot = getImage();
Expand Down Expand Up @@ -276,10 +271,6 @@ public void testShouldCaptureScreenshotOfPageWithTooLongXandY() {

@Test
public void testShouldCaptureScreenshotAtFramePage() {
// Fails on Sauce for whatever reason; probably display or window manager.
assumeFalse(SauceDriver.shouldUseSauce()
&& getEffectivePlatform(driver).is(LINUX)
&& isChrome(driver));
driver.get(appServer.whereIs("screen/screen_frames.html"));
wait.until(frameToBeAvailableAndSwitchToIt(By.id("frame1")));
wait.until(visibilityOfAllElementsLocatedBy(By.id("content")));
Expand Down Expand Up @@ -339,10 +330,6 @@ public void testShouldCaptureScreenshotAtIFramePage() {
@Test
@Ignore(MARIONETTE)
public void testShouldCaptureScreenshotAtFramePageAfterSwitching() {
// Fails on Sauce for whatever reason; probably display or window manager.
assumeFalse(SauceDriver.shouldUseSauce()
&& getEffectivePlatform(driver).is(LINUX)
&& isChrome(driver));
driver.get(appServer.whereIs("screen/screen_frames.html"));

driver.switchTo().frame(driver.findElement(By.id("frame2")));
Expand Down
29 changes: 0 additions & 29 deletions java/client/test/org/openqa/selenium/WindowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.SwitchToTopAfterTest;
import org.openqa.selenium.testing.TestUtilities;
import org.openqa.selenium.testing.drivers.SauceDriver;

import java.util.function.Consumer;

Expand All @@ -47,9 +46,6 @@ public void testSetsTheSizeOfTheCurrentWindow() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeFalse("https://bugs.chromium.org/p/chromedriver/issues/detail?id=1129",
SauceDriver.shouldUseSauce() && TestUtilities.isChrome(driver)
&& TestUtilities.getEffectivePlatform(driver).is(LINUX));
// resize relative to the initial size, since we don't know what it is
changeSizeBy(-20, -20);
}
Expand All @@ -60,9 +56,6 @@ public void testSetsTheSizeOfTheCurrentWindowFromFrame() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeFalse("https://bugs.chromium.org/p/chromedriver/issues/detail?id=1129",
SauceDriver.shouldUseSauce() && TestUtilities.isChrome(driver)
&& TestUtilities.getEffectivePlatform(driver).is(LINUX));
driver.get(pages.framesetPage);
driver.switchTo().frame("fourth");
// resize relative to the initial size, since we don't know what it is
Expand All @@ -75,9 +68,6 @@ public void testSetsTheSizeOfTheCurrentWindowFromIframe() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeFalse("https://bugs.chromium.org/p/chromedriver/issues/detail?id=1129",
SauceDriver.shouldUseSauce() && TestUtilities.isChrome(driver)
&& TestUtilities.getEffectivePlatform(driver).is(LINUX));
driver.get(pages.iframePage);
driver.switchTo().frame("iframe1-name");
// resize relative to the initial size, since we don't know what it is
Expand All @@ -103,9 +93,6 @@ public void testSetsThePositionOfTheCurrentWindow() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeFalse("https://bugs.chromium.org/p/chromedriver/issues/detail?id=1129",
SauceDriver.shouldUseSauce() && TestUtilities.isChrome(driver)
&& TestUtilities.getEffectivePlatform(driver).is(LINUX));
WebDriver.Window window = driver.manage().window();
Point position = window.getPosition();
Dimension originalSize = window.getSize();
Expand All @@ -131,7 +118,6 @@ public void testCanMaximizeTheWindow() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeNotLinuxAtSauce();

changeSizeTo(new Dimension(640, 273));
enlargeBy(WebDriver.Window::maximize);
Expand All @@ -144,7 +130,6 @@ public void testCanMaximizeTheWindowFromFrame() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeNotLinuxAtSauce();

driver.get(pages.framesetPage);
changeSizeTo(new Dimension(640, 274));
Expand All @@ -160,7 +145,6 @@ public void testCanMaximizeTheWindowFromIframe() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeNotLinuxAtSauce();

driver.get(pages.iframePage);
changeSizeTo(new Dimension(640, 275));
Expand All @@ -175,7 +159,6 @@ public void canFullscreenTheWindow() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeNotLinuxAtSauce();

changeSizeTo(new Dimension(640, 273));
enlargeBy(WebDriver.Window::fullscreen);
Expand All @@ -188,7 +171,6 @@ public void canFullscreenTheWindowFromFrame() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeNotLinuxAtSauce();

driver.get(pages.framesetPage);
changeSizeTo(new Dimension(640, 274));
Expand All @@ -204,7 +186,6 @@ public void canFullscreenTheWindowFromIframe() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));
assumeNotLinuxAtSauce();

driver.get(pages.iframePage);
changeSizeTo(new Dimension(640, 275));
Expand Down Expand Up @@ -241,14 +222,4 @@ private ExpectedCondition<Boolean> windowSizeEqual(final Dimension size) {
return newSize.height == size.height && newSize.width == size.width;
};
}

private void assumeNotLinuxAtSauce() {
// Tests that maximize browser window used to fail when Sauce didn't run a window manager
// on Linux. 2015-07-16, they still fail although Sauce reportedly runs metacity.
// Chrome/Linux: simply fail.
// Firefox/Linux: FirefoxDriver finally report a changed window size 22 seconds after replying
// the maximize command, but video never shows the maximized window.
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(LINUX) && SauceDriver.shouldUseSauce());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.openqa.selenium.testing.NeedsLocalEnvironment;
import org.openqa.selenium.testing.NoDriverAfterTest;
import org.openqa.selenium.testing.NotYetImplemented;
import org.openqa.selenium.testing.drivers.SauceDriver;
import org.openqa.selenium.testing.drivers.WebDriverBuilder;

import java.io.File;
Expand Down Expand Up @@ -409,12 +408,7 @@ private static String randomString() {

@Test
public void multipleFirefoxDriversRunningConcurrently() throws Exception {
int numThreads;
if (!SauceDriver.shouldUseSauce()) {
numThreads = 6;
} else {
numThreads = 2;
}
int numThreads = 6;
final int numRoundsPerThread = 5;
WebDriver[] drivers = new WebDriver[numThreads];
List<Worker> workers = new ArrayList<>(numThreads);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.testing.drivers.Browser;
import org.openqa.selenium.testing.drivers.SauceDriver;
import org.openqa.selenium.testing.drivers.WebDriverBuilder;

import java.util.logging.Logger;
Expand Down Expand Up @@ -271,8 +270,7 @@ private static boolean matches(Browser browser, Driver[] drivers) {

case REMOTE:
if (Boolean.getBoolean("selenium.browser.grid") ||
Boolean.getBoolean("selenium.browser.remote") ||
SauceDriver.shouldUseSauce()) {
Boolean.getBoolean("selenium.browser.remote")) {
return true;
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.testing.drivers.SauceDriver;

import java.util.Map;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -181,10 +180,6 @@ public static int getIEVersion(WebDriver driver) {


public static Platform getEffectivePlatform() {
if (SauceDriver.shouldUseSauce()) {
return SauceDriver.getEffectivePlatform();
}

return Platform.getCurrent();
}

Expand All @@ -201,7 +196,8 @@ public static Platform getEffectivePlatform(WebDriver driver) {
}

public static boolean isLocal() {
return !Boolean.getBoolean("selenium.browser.remote") && !SauceDriver.shouldUseSauce();
return ! (Boolean.getBoolean("selenium.browser.remote")
|| Boolean.getBoolean("selenium.browser.grid"));
}

public static boolean isOnTravis() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public TestChromeDriver(Capabilities capabilities) {

private static URL getServiceUrl() {
try {
if (service == null && !SauceDriver.shouldUseSauce()) {
if (service == null) {
Path logFile = Files.createTempFile("chromedriver", ".log");
service = new ChromeDriverService.Builder()
.withVerbose(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.openqa.selenium.Platform;
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.IgnoreList;
import org.openqa.selenium.testing.NeedsLocalEnvironment;

import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -97,32 +96,13 @@ public boolean isIgnored(Description method) {

ignored |= isIgnoredDueToEnvironmentVariables(method);

ignored |= isIgnoredDueToBeingOnSauce(method);

return ignored;
}

private boolean isIgnoredBecauseOfJUnit4Ignore(org.junit.Ignore annotation) {
return annotation != null;
}

private static Platform getEffectivePlatform() {
if (SauceDriver.shouldUseSauce()) {
return SauceDriver.getEffectivePlatform();
}

return Platform.getCurrent();
}

private boolean isIgnoredDueToBeingOnSauce(Description method) {
boolean isLocal = method.getAnnotation(NeedsLocalEnvironment.class) != null
|| method.getTestClass().getAnnotation(NeedsLocalEnvironment.class) != null;
if (SauceDriver.shouldUseSauce()) {
return isLocal;
}
return Boolean.getBoolean("local_only") && !isLocal;
}

private boolean isIgnoredDueToEnvironmentVariables(Description method) {
return (!only.isEmpty() && !only.contains(method.getTestClass().getSimpleName())) ||
(!methods.isEmpty() && !methods.contains(method.getMethodName())) ||
Expand All @@ -139,8 +119,7 @@ public void setBrowser(Browser browser) {

private void addIgnoresForBrowser(Browser browser, IgnoreComparator comparator) {
if (Boolean.getBoolean("selenium.browser.remote")
|| Boolean.getBoolean("selenium.browser.grid")
|| SauceDriver.shouldUseSauce()) {
|| Boolean.getBoolean("selenium.browser.grid")) {
comparator.addDriver(REMOTE);
}
if (Boolean.getBoolean("selenium.browser.grid")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public TestOperaBlinkDriver(Capabilities capabilities) {
}

private static URL getServiceUrl() {
if (service == null && !SauceDriver.shouldUseSauce()) {
if (service == null) {
service = OperaDriverService.createDefaultService();
try {
service.start();
Expand Down

0 comments on commit 2613fc3

Please sign in to comment.