Skip to content

Commit

Permalink
Remove deprecated or old, unused code from selenium module
Browse files Browse the repository at this point in the history
  • Loading branch information
ralph-steiner committed Jan 29, 2025
1 parent 58655b1 commit e42ba5c
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.eclipse.scout.rt.platform.config.AbstractBooleanConfigProperty;
import org.eclipse.scout.rt.platform.config.AbstractMapConfigProperty;
import org.eclipse.scout.rt.platform.config.AbstractStringConfigProperty;
import org.eclipse.scout.rt.platform.util.TypeCastUtility;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.edge.EdgeDriverService;
import org.openqa.selenium.firefox.FirefoxDriverService;
Expand Down Expand Up @@ -90,12 +89,6 @@ public String getKey() {
public String description() {
return "If set, unit tests simulate slow network";
}

@Override
public Boolean getDefaultValue() {
// support for legacy system property
return System.getProperty("slow.network") != null;
}
}

public static class SeleniumWebAppUrlProperty extends AbstractStringConfigProperty {
Expand All @@ -109,12 +102,6 @@ public String getKey() {
public String description() {
return "URL to web application under test";
}

@Override
public String getDefaultValue() {
// support for legacy system property
return System.getProperty("web.app.url", "http://localhost:8082/");
}
}

public static class SeleniumWebQueryParamsProperty extends AbstractStringConfigProperty {
Expand All @@ -128,12 +115,6 @@ public String getKey() {
public String description() {
return "Query params appended to web application under test";
}

@Override
public String getDefaultValue() {
// support for legacy system property
return System.getProperty("query.params", "debug=true");
}
}

public static class SeleniumScreenshotOnFailureProperty extends AbstractBooleanConfigProperty {
Expand All @@ -147,11 +128,5 @@ public String getKey() {
public String description() {
return "If set, then a screenshot is taken in case of a failed test";
}

@Override
public Boolean getDefaultValue() {
// support for legacy system property
return TypeCastUtility.castValue(System.getProperty("take.screenshot.on.failure"), boolean.class);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.eclipse.scout.rt.ui.html.selenium;

import org.eclipse.scout.rt.platform.BEANS;
import org.eclipse.scout.rt.ui.html.selenium.util.SeleniumDriver;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
Expand All @@ -29,7 +30,7 @@ private SeleniumSuiteState() {
}

public static void setUpBeforeClass() {
s_driver = SeleniumDriver.setUpDriver();
s_driver = BEANS.get(SeleniumDriver.class).createDriver();
s_suiteStarted = true;
LOG.info("Selenium driver started by {}", SeleniumSuiteState.class.getSimpleName());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/*
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
* Copyright (c) 2010, 2025 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.scout.rt.ui.html.selenium.junit;
package org.eclipse.scout.rt.ui.html.selenium.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.eclipse.scout.rt.ui.html.selenium.junit.RetryOnFailureRule;

/**
* Indicates that the annotated test (or tests if used on class level) should be retried automatically when it fails.
* Only after all of the given number of retries have failed, the test is reported as broken.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.eclipse.scout.rt.client.ui.form.fields.IValueField;
import org.eclipse.scout.rt.client.ui.messagebox.MessageBox;
import org.eclipse.scout.rt.platform.BEANS;
import org.eclipse.scout.rt.ui.html.selenium.SeleniumSuiteState;
import org.eclipse.scout.rt.ui.html.selenium.util.SeleniumDriver;
import org.eclipse.scout.rt.ui.html.selenium.util.SeleniumExpectedConditions;
Expand Down Expand Up @@ -79,7 +80,7 @@ public static void setUpBeforeClass() {
s_driver = SeleniumSuiteState.getDriver();
}
else {
s_driver = SeleniumDriver.setUpDriver();
s_driver = BEANS.get(SeleniumDriver.class).createDriver();
LOG.info("Selenium driver started by AbstractSeleniumTest");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.eclipse.scout.rt.ui.html.selenium.junit;

import org.eclipse.scout.rt.ui.html.selenium.annotation.RetryOnFailure;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
package org.eclipse.scout.rt.ui.html.selenium.util;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
Expand All @@ -19,14 +18,11 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.regex.Pattern;

import org.apache.commons.exec.OS;
import org.eclipse.scout.rt.platform.ApplicationScoped;
import org.eclipse.scout.rt.platform.BEANS;
import org.eclipse.scout.rt.platform.config.CONFIG;
import org.eclipse.scout.rt.platform.exception.DefaultRuntimeExceptionTranslator;
import org.eclipse.scout.rt.platform.exception.PlatformException;
import org.eclipse.scout.rt.platform.util.BooleanUtility;
import org.eclipse.scout.rt.platform.util.CollectionUtility;
import org.eclipse.scout.rt.platform.util.ObjectUtility;
Expand All @@ -41,7 +37,6 @@
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.firefox.FirefoxOptions;
Expand All @@ -58,17 +53,8 @@
public class SeleniumDriver {
private static final Logger LOG = LoggerFactory.getLogger(SeleniumDriver.class);

public static WebDriver setUpDriver() {
return BEANS.get(SeleniumDriver.class).createDriver();
}

public WebDriver createDriver() {
if (CONFIG.getPropertyValue(SeleniumDriverConfigProperty.class) != null) {
loadDriverProperties();
}
else {
legacySetup();
}
loadDriverProperties();

// ensure proxy properties do not contain an empty string
String proxyHostProperty = "http.proxyHost";
Expand Down Expand Up @@ -141,46 +127,6 @@ protected ClientConfig getClientConfig() {
}
}

/**
* Old legacy code which will be used if no scout selenium config properties are set.
*/
protected void legacySetup() {
// web-driver executable
String webdriverChromeDriver = System.getProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY);
if (StringUtility.isNullOrEmpty(webdriverChromeDriver)) {
webdriverChromeDriver = OS.isFamilyWindows() ? "/seleniumDrivers/chromedriver.exe" : "/seleniumDrivers/chromedriver";
}

File chromeDriver = new File(webdriverChromeDriver);
if (!chromeDriver.exists()) {
LOG.info("Chrome driver executable not found at path: {}", chromeDriver);
URL webdriverChromeDriverResource = SeleniumDriver.class.getResource(webdriverChromeDriver);
if (webdriverChromeDriverResource != null) {
chromeDriver = new File(webdriverChromeDriverResource.getFile());
webdriverChromeDriver = chromeDriver.getAbsolutePath();
}
}
if (!StringUtility.matches(webdriverChromeDriver, ".+\\.exe", Pattern.CASE_INSENSITIVE) && chromeDriver.exists() && !chromeDriver.canExecute()) {
boolean success = chromeDriver.setExecutable(true);
if (!success) {
throw new PlatformException("Error making '{}' executable.", chromeDriver);
}
}

System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, webdriverChromeDriver);
LOG.info("set property '" + ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY + "': " + webdriverChromeDriver);

// log-file for web-driver
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File logFile = new File(tmpDir, "webdriver.log");
String logFilePath = logFile.getAbsolutePath();
System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, logFilePath);
LOG.info("set property '" + ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY + "': " + logFilePath);

// set web-driver in verbose mode
System.setProperty(ChromeDriverService.CHROME_DRIVER_VERBOSE_LOG_PROPERTY, "true");
}

protected RemoteWebDriver createRemoteDriver() {
return (RemoteWebDriver) RemoteWebDriver.builder()
.oneOf(getDriverOptions())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,6 @@ public static String debugElement(WebElement element) {
}
}

/**
* @return Whether the VM runs on Windows 8.x.
*/
public static boolean isWindows8() {
return StringUtility.containsString(System.getProperty("os.name"), "Windows 8");
}

public static boolean isMacOS() {
return StringUtility.containsString(System.getProperty("os.name"), "Mac OS");
}
Expand Down

0 comments on commit e42ba5c

Please # to comment.