Skip to content

Commit

Permalink
Updated to Selenium 4.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Mar 29, 2023
1 parent 5df1b3f commit 3588a16
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 99 deletions.
15 changes: 13 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
<commons.net.version>3.9.0</commons.net.version>
<commons.codec.version>1.15</commons.codec.version>
<freemarker.version>2.3.32</freemarker.version>
<selenium.version>4.8.1</selenium.version>
<selenium.version>4.8.3</selenium.version>
<htmlunit.driver.version>4.8.1</htmlunit.driver.version>
<jsonassert.version>1.5.1</jsonassert.version>
<jsoup.version>1.14.3</jsoup.version>
<joda-time.version>2.12.2</joda-time.version>
Expand All @@ -75,7 +76,7 @@
<freemarker.version>2.3.31</freemarker.version>
<appium.version>8.3.0</appium.version>
<fluentlenium.version>0.10.2</fluentlenium.version>
<htmlunit.version>3.62.0</htmlunit.version>
<htmlunit.version>3.0.0</htmlunit.version>
<webdrivermanager.version>5.3.0</webdrivermanager.version>
<filters.version>2.0.235</filters.version>
<ngwebdriver.version>1.1.6</ngwebdriver.version>
Expand Down Expand Up @@ -384,6 +385,16 @@
<artifactId>selenium-opera-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>${htmlunit.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit3-driver</artifactId>
<version>${htmlunit.driver.version}</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
Expand Down
8 changes: 8 additions & 0 deletions serenity-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit3-driver</artifactId>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public <T> T waitFor(String message, final ExpectedCondition<T> expectedConditio
return doWait().until(new WaitForWithMessage<>(message, expectedCondition));
}

public WebElementFacade waitFor(String xpathOrCssSelector) {
return waitFor(xpathOrCssSelector(xpathOrCssSelector));
public WebElementFacade waitFor(String xpathOrCssSelector, Object... args) {
return waitFor(formattedXpathOrCssSelector(xpathOrCssSelector, args));
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
//package net.serenitybdd.core.webdriver.driverproviders;
//
//import net.serenitybdd.core.buildinfo.DriverCapabilityRecord;
//import net.serenitybdd.core.di.WebDriverInjectors;
//import net.serenitybdd.core.webdriver.driverproviders.webdrivermanager.WebDriverManagerSetup;
//import net.thucydides.core.fixtureservices.FixtureProviderService;
//import net.thucydides.core.steps.StepEventBus;
//import net.thucydides.core.util.EnvironmentVariables;
//import net.thucydides.core.webdriver.CapabilityEnhancer;
//import net.thucydides.core.webdriver.SupportedWebDriver;
//import net.thucydides.core.webdriver.stubs.WebDriverStub;
//import org.openqa.selenium.Capabilities;
//import org.openqa.selenium.MutableCapabilities;
//import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.htmlunit.HtmlUnitDriver;
//import org.openqa.selenium.remote.DesiredCapabilities;
//import org.openqa.selenium.safari.SafariDriver;
//import org.openqa.selenium.safari.SafariOptions;
//
///**
// * HTMLUnit provider.
// * Experimental: used mostly for testing.
// */
//public class HTMLUnitDriverProvider implements DriverProvider {
//
// private final DriverCapabilityRecord driverProperties;
//
// private final FixtureProviderService fixtureProviderService;
//
// public HTMLUnitDriverProvider(FixtureProviderService fixtureProviderService) {
// this.fixtureProviderService = fixtureProviderService;
// this.driverProperties = WebDriverInjectors.getInjector().getInstance(DriverCapabilityRecord.class);
// }
//
// @Override
// public WebDriver newInstance(String options, EnvironmentVariables environmentVariables) {
// if (StepEventBus.getParallelEventBus().webdriverCallsAreSuspended()) {
// return new WebDriverStub();
// }
//
// CapabilityEnhancer enhancer = new CapabilityEnhancer(environmentVariables, fixtureProviderService);
// MutableCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability("browserName","htmlunit");
// capabilities = enhancer.enhanced(capabilities, SupportedWebDriver.HTMLUNIT);
//
// WebDriver driver = new HtmlUnitDriver(capabilities);
// driverProperties.registerCapabilities("htmlunit", capabilitiesToProperties(capabilities));
// return driver;
// }
//}
package net.serenitybdd.core.webdriver.driverproviders;

import net.serenitybdd.core.buildinfo.DriverCapabilityRecord;
import net.serenitybdd.core.di.WebDriverInjectors;
import net.thucydides.core.fixtureservices.FixtureProviderService;
import net.thucydides.core.steps.StepEventBus;
import net.thucydides.core.util.EnvironmentVariables;
import net.thucydides.core.webdriver.CapabilityEnhancer;
import net.thucydides.core.webdriver.SupportedWebDriver;
import net.thucydides.core.webdriver.stubs.WebDriverStub;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

/**
* HTMLUnit provider.
* Experimental: used mostly for testing.
*/
public class HTMLUnitDriverProvider implements DriverProvider {

private final DriverCapabilityRecord driverProperties;

private final FixtureProviderService fixtureProviderService;

public HTMLUnitDriverProvider(FixtureProviderService fixtureProviderService) {
this.fixtureProviderService = fixtureProviderService;
this.driverProperties = WebDriverInjectors.getInjector().getInstance(DriverCapabilityRecord.class);
}

@Override
public WebDriver newInstance(String options, EnvironmentVariables environmentVariables) {
if (StepEventBus.getParallelEventBus().webdriverCallsAreSuspended()) {
return new WebDriverStub();
}

CapabilityEnhancer enhancer = new CapabilityEnhancer(environmentVariables, fixtureProviderService);
MutableCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "htmlunit");
capabilities = enhancer.enhanced(capabilities, SupportedWebDriver.HTMLUNIT);

WebDriver driver = new HtmlUnitDriver(capabilities);
driverProperties.registerCapabilities("htmlunit", capabilitiesToProperties(capabilities));
return driver;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -974,12 +974,10 @@ public void currentStepDone(TestResult result) {
}

private boolean currentStepExists() {
// return !currentStepStack.get().isEmpty();
return !currentStepStack.isEmpty();
}

public int getCurrentLevel() {
// return currentStepStack.get().size();
return currentStepStack.size();
}

Expand Down Expand Up @@ -1103,7 +1101,7 @@ private void removeFirstScreenshotOfCurrentStep() {
}

private boolean currentStepHasMoreThanOneScreenshot() {
return getCurrentStep().getScreenshotCount() > 1;
return currentStepExists() && getCurrentStep().getScreenshotCount() > 1;
}

private ScreenshotAndHtmlSource lastScreenshotOf(TestStep testStep) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -58,10 +59,10 @@ public enum SupportedWebDriver {
*/
SAFARI(SafariDriver.class),

// /**
// * HtmlUnit
// */
// HTMLUNIT(HtmlUnitDriver.class),
/**
* HtmlUnit
*/
HTMLUNIT(HtmlUnitDriver.class),
/**
* Appium
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private Map<SupportedWebDriver, DriverProvider> driverProviders() {
driverProvidersByDriverType.put(SupportedWebDriver.FIREFOX, new FirefoxDriverProvider(fixtureProviderService));
driverProvidersByDriverType.put(SupportedWebDriver.SAFARI, new SafariDriverProvider(fixtureProviderService));
driverProvidersByDriverType.put(SupportedWebDriver.IEXPLORER, new InternetExplorerDriverProvider(fixtureProviderService));
driverProvidersByDriverType.put(SupportedWebDriver.HTMLUNIT, new HTMLUnitDriverProvider(fixtureProviderService));
driverProvidersByDriverType.put(SupportedWebDriver.PROVIDED, new ProvidedDriverProvider());
// LEGACY PROVIDERS
driverProvidersByDriverType.put(SupportedWebDriver.APPIUM, new AppiumDriverProvider(fixtureProviderService));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,11 @@ private Method getProcessedMethod(String className, String methodName, List<Clas
Class[] classesArray = new Class[methodParameterClasses.size()];
return Class.forName(className).getMethod(methodName, methodParameterClasses.toArray(classesArray));
}
// check whether the class with name className has a method with name methodName and return it if it exists
if (Arrays.stream(Class.forName(className).getDeclaredMethods()).anyMatch(method -> method.getName().equals(methodName))) {
return Class.forName(className).getDeclaredMethod(methodName);
}
return Class.forName(className).getMethod(methodName);

}

private boolean isNullOrEmpty(List<Class> methodParameterClasses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ void sample_test() {
@Nested
class Nested_Test_Cases {


@Test
void sample_nested_test() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
/**
* Generate aggregate XML acceptance test reports.
*/
//@Mojo(name = "aggregate", requiresProject = false, requiresDependencyResolution = ResolutionScope.RUNTIME, aggregator = true)
@Mojo(name = "aggregate", requiresDependencyResolution = ResolutionScope.RUNTIME, aggregator = true)
@Mojo(name = "aggregate", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, aggregator = true)
public class SerenityAggregatorMojo extends AbstractMojo {

private final static Logger LOGGER = LoggerFactory.getLogger(SerenityAggregatorMojo.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This plugin checks for the presence of failing tests in the target directory.
* You typically run this goal directly after the aggregate goal, to ensure that the build fails if there are errors.
*/
@Mojo(name = "check", requiresDependencyResolution = ResolutionScope.RUNTIME)
@Mojo(name = "check", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class SerenityCheckMojo extends AbstractMojo {
/**
* Aggregate reports are generated here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* - Duplicate feature file names with the same parent folder names
* - Gherkin syntax errors
*/
@Mojo(name = "check-gherkin", requiresDependencyResolution = ResolutionScope.RUNTIME)
@Mojo(name = "check-gherkin", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class SerenityGherkinCheckerMojo extends AbstractMojo {

@Parameter(defaultValue = "${session}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* This allows extended reports to be generated independently of the full aggregate report, and opens the possibility
* of more tailored next-generation reporting.
*/
@Mojo(name = "reports", requiresProject = false, requiresDependencyResolution = ResolutionScope.RUNTIME)
@Mojo(name = "reports", requiresProject = false, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class SerenityReportMojo extends AbstractMojo {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -492,7 +493,9 @@ private TestResult getResultFromChildren() {
private List<TestResult> getChildResults() {
List<TestResult> childResults = new ArrayList<>();
for (TestStep step : getChildren()) {
childResults.add(step.getResult());
if (step != null && step.getResult() != null) {
childResults.add(step.getResult());
}
}
return childResults;
}
Expand Down
26 changes: 0 additions & 26 deletions serenity-rest-assured/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,6 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<exclusions>
<!-- <exclusion>-->
<!-- <groupId>org.apache.httpcomponents</groupId>-->
<!-- <artifactId>httpclient</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>org.apache.httpcomponents</groupId>-->
<!-- <artifactId>httpmime</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>org.codehaus.groovy</groupId>-->
<!-- <artifactId>groovy</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>org.codehaus.groovy</groupId>-->
<!-- <artifactId>groovy-json</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>org.codehaus.groovy</groupId>-->
<!-- <artifactId>groovy-xml</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>org.apache.commons</groupId>-->
<!-- <artifactId>commons-lang3</artifactId>-->
<!-- </exclusion>-->
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import net.serenitybdd.screenplay.webtests.integration.ScreenplayInteractionTestBase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.devtools.v108.performance.Performance;
import org.openqa.selenium.devtools.v108.performance.model.Metric;
import org.openqa.selenium.devtools.v111.performance.Performance;
import org.openqa.selenium.devtools.v111.performance.model.Metric;

import java.util.ArrayList;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion serenity-smoketests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>serenity-bdd</artifactId>
<groupId>net.serenity-bdd</groupId>
<version>3.6.21-SNAPSHOT</version>
<version>3.6.22-SNAPSHOT</version>
</parent>
<artifactId>serenity-smoketests</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ public void should_see_how_to_begin_with_page_objects() {

james.should_see_that_the_placeholder_text_says("What needs to be done?");
}
}
}

0 comments on commit 3588a16

Please sign in to comment.