Skip to content

Commit e842eca

Browse files
authored
Update to Selenium 4.24.0 (#96) +semver:feature
* Update to Selenium 4.24.0 Stabilize wait for FindElements in the ElementFactory * Update to get rid of deprecated tasks from azure-pipelines.yml for Azure Pipelines, remove update of java heap space
1 parent 6f0f4ac commit e842eca

File tree

3 files changed

+49
-39
lines changed

3 files changed

+49
-39
lines changed

azure-pipelines.yml

+22-17
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,36 @@ jobs:
99
displayName: Analyse code with SonarQube
1010

1111
steps:
12-
- task: SonarCloudPrepare@1
12+
- task: SonarCloudPrepare@2
1313
displayName: 'Prepare SonarCloud analysis'
1414
inputs:
1515
SonarCloud: 'SonarCloud'
1616
organization: 'aqualityautomation'
1717
scannerMode: 'CLI'
1818
configMode: 'file'
19-
extraProperties: |
20-
sonar.coverage.exclusions=**/**
19+
extraProperties: 'sonar.coverage.exclusions=**/**'
2120

22-
- task: Maven@3
21+
- task: Maven@4
2322
displayName: 'Build project'
2423
inputs:
2524
mavenPomFile: 'pom.xml'
26-
mavenOptions: '-Xmx3072m'
27-
javaHomeOption: 'JDKVersion'
28-
jdkVersionOption: '11'
29-
jdkArchitectureOption: 'x64'
25+
goals: 'clean'
3026
publishJUnitResults: true
3127
testResultsFiles: '**/surefire-reports/TEST-*.xml'
32-
goals: 'clean'
28+
javaHomeOption: 'JDKVersion'
29+
jdkVersionOption: '1.11'
30+
mavenVersionOption: 'Default'
31+
mavenAuthenticateFeed: false
32+
effectivePomSkip: false
33+
sonarQubeRunAnalysis: false
3334

34-
- task: SonarCloudAnalyze@1
35+
- task: SonarCloudAnalyze@2
36+
inputs:
37+
jdkversion: 'JAVA_HOME_21_X64'
3538
displayName: 'Run SonarCloud code analysis'
3639
continueOnError: true
3740

38-
- task: SonarCloudPublish@1
41+
- task: SonarCloudPublish@2
3942
displayName: 'Publish SonarCloud quality gate results'
4043
inputs:
4144
pollingTimeoutSec: '300'
@@ -89,14 +92,16 @@ jobs:
8992
inputs:
9093
displaySettings: 'optimal'
9194

92-
- task: Maven@3
95+
- task: Maven@4
9396
displayName: 'Run tests'
9497
inputs:
9598
mavenPomFile: 'pom.xml'
96-
mavenOptions: '-Xmx3072m'
97-
javaHomeOption: 'JDKVersion'
98-
jdkVersionOption: '11'
99-
jdkArchitectureOption: 'x64'
99+
goals: 'clean test -Dprofile=local'
100100
publishJUnitResults: true
101101
testResultsFiles: '**/surefire-reports/TEST-*.xml'
102-
goals: 'clean test -Dprofile=local'
102+
javaHomeOption: 'JDKVersion'
103+
jdkVersionOption: '1.11'
104+
mavenVersionOption: 'Default'
105+
mavenAuthenticateFeed: false
106+
effectivePomSkip: false
107+
sonarQubeRunAnalysis: false

pom.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1818
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1919
<revision>4.0.0-SNAPSHOT</revision>
20-
<log4j.version>2.23.1</log4j.version>
20+
<log4j.version>2.24.0</log4j.version>
2121
</properties>
2222

2323
<distributionManagement>
@@ -121,28 +121,28 @@
121121
<dependency>
122122
<groupId>com.google.guava</groupId>
123123
<artifactId>guava</artifactId>
124-
<version>33.1.0-jre</version>
124+
<version>33.3.0-jre</version>
125125
</dependency>
126126
<dependency>
127127
<groupId>com.fasterxml.jackson.core</groupId>
128128
<artifactId>jackson-databind</artifactId>
129-
<version>2.17.0</version>
129+
<version>2.17.2</version>
130130
</dependency>
131131
<dependency>
132132
<groupId>org.seleniumhq.selenium</groupId>
133133
<artifactId>selenium-java</artifactId>
134-
<version>4.23.0</version>
134+
<version>4.24.0</version>
135135
</dependency>
136136
<dependency>
137137
<groupId>io.appium</groupId>
138138
<artifactId>java-client</artifactId>
139-
<version>9.2.3</version>
139+
<version>9.3.0</version>
140140
<scope>test</scope>
141141
</dependency>
142142
<dependency>
143143
<groupId>org.apache.commons</groupId>
144144
<artifactId>commons-lang3</artifactId>
145-
<version>3.14.0</version>
145+
<version>3.17.0</version>
146146
<scope>test</scope>
147147
</dependency>
148148
</dependencies>

src/main/java/aquality/selenium/core/elements/ElementFactory.java

+21-16
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@
88
import aquality.selenium.core.logging.Logger;
99
import aquality.selenium.core.waitings.IConditionalWait;
1010
import com.google.inject.Inject;
11-
import org.openqa.selenium.By;
11+
import org.openqa.selenium.*;
1212
import org.openqa.selenium.By.ByTagName;
1313
import org.openqa.selenium.By.ByXPath;
14-
import org.openqa.selenium.InvalidArgumentException;
15-
import org.openqa.selenium.WebElement;
1614
import org.openqa.selenium.support.pagefactory.ByChained;
1715

1816
import java.lang.reflect.Constructor;
1917
import java.lang.reflect.InvocationTargetException;
2018
import java.time.Duration;
21-
import java.util.ArrayList;
22-
import java.util.HashMap;
23-
import java.util.List;
24-
import java.util.Map;
19+
import java.util.*;
2520
import java.util.concurrent.TimeoutException;
2621

2722
public class ElementFactory implements IElementFactory {
@@ -87,16 +82,26 @@ public <T extends IElement> List<T> findElements(By locator, String name, IEleme
8782
} catch (TimeoutException e) {
8883
throw new org.openqa.selenium.TimeoutException(e.getMessage());
8984
}
90-
List<WebElement> webElements = elementFinder.findElements(locator, state, ZERO_TIMEOUT);
9185
String namePrefix = name == null ? "element" : name;
92-
List<T> list = new ArrayList<>();
93-
for (int index = 1; index <= webElements.size(); index++) {
94-
WebElement webElement = webElements.get(index - 1);
95-
String currentName = String.format("%1$s %2$s", namePrefix, index);
96-
T element = supplier.get(generateLocator(locator, webElement, index), currentName, state);
97-
list.add(element);
98-
}
99-
return list;
86+
List<T> elements = new ArrayList<>();
87+
Collection<Class<? extends Throwable>> ignoredExceptions = Arrays.asList(
88+
StaleElementReferenceException.class, JavascriptException.class, org.openqa.selenium.TimeoutException.class
89+
);
90+
conditionalWait.waitFor(() -> {
91+
List<WebElement> webElements = elementFinder.findElements(locator, state, ZERO_TIMEOUT);
92+
for (int index = 1; index <= webElements.size(); index++) {
93+
WebElement webElement = webElements.get(index - 1);
94+
String currentName = String.format("%1$s %2$s", namePrefix, index);
95+
T element = supplier.get(generateLocator(locator, webElement, index), currentName, state);
96+
elements.add(element);
97+
}
98+
boolean anyElementsFound = !elements.isEmpty();
99+
return count == ElementsCount.ANY
100+
|| (count == ElementsCount.ZERO && !anyElementsFound)
101+
|| (count == ElementsCount.MORE_THAN_ZERO && anyElementsFound);
102+
}, ignoredExceptions);
103+
104+
return elements;
100105
}
101106

102107
protected void waitForElementsCount(By locator, ElementsCount count, ElementState state) throws TimeoutException {

0 commit comments

Comments
 (0)