Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Selenium 4.24.0 #96

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,37 @@ jobs:
displayName: Analyse code with SonarQube

steps:
- task: SonarCloudPrepare@1
- task: SonarCloudPrepare@2
displayName: 'Prepare SonarCloud analysis'
inputs:
SonarCloud: 'SonarCloud'
organization: 'aqualityautomation'
scannerMode: 'CLI'
configMode: 'file'
extraProperties: |
sonar.coverage.exclusions=**/**
extraProperties: 'sonar.coverage.exclusions=**/**'

- task: Maven@3
- task: Maven@4
displayName: 'Build project'
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '11'
jdkArchitectureOption: 'x64'
goals: 'clean'
options: '-Xmx3072m'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'clean'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false

- task: SonarCloudAnalyze@1
- task: SonarCloudAnalyze@2
inputs:
jdkversion: 'JAVA_HOME'
displayName: 'Run SonarCloud code analysis'
continueOnError: true

- task: SonarCloudPublish@1
- task: SonarCloudPublish@2
displayName: 'Publish SonarCloud quality gate results'
inputs:
pollingTimeoutSec: '300'
Expand Down Expand Up @@ -89,14 +93,17 @@ jobs:
inputs:
displaySettings: 'optimal'

- task: Maven@3
- task: Maven@4
displayName: 'Run tests'
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '11'
jdkArchitectureOption: 'x64'
goals: 'clean test -Dprofile=local'
options: '-Xmx3072m'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'clean test -Dprofile=local'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>4.0.0-SNAPSHOT</revision>
<log4j.version>2.23.1</log4j.version>
<log4j.version>2.24.0</log4j.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -121,28 +121,28 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.1.0-jre</version>
<version>33.3.0-jre</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.23.0</version>
<version>4.24.0</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>9.2.3</version>
<version>9.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>3.17.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
37 changes: 21 additions & 16 deletions src/main/java/aquality/selenium/core/elements/ElementFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@
import aquality.selenium.core.logging.Logger;
import aquality.selenium.core.waitings.IConditionalWait;
import com.google.inject.Inject;
import org.openqa.selenium.By;
import org.openqa.selenium.*;
import org.openqa.selenium.By.ByTagName;
import org.openqa.selenium.By.ByXPath;
import org.openqa.selenium.InvalidArgumentException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.pagefactory.ByChained;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeoutException;

public class ElementFactory implements IElementFactory {
Expand Down Expand Up @@ -87,16 +82,26 @@ public <T extends IElement> List<T> findElements(By locator, String name, IEleme
} catch (TimeoutException e) {
throw new org.openqa.selenium.TimeoutException(e.getMessage());
}
List<WebElement> webElements = elementFinder.findElements(locator, state, ZERO_TIMEOUT);
String namePrefix = name == null ? "element" : name;
List<T> list = new ArrayList<>();
for (int index = 1; index <= webElements.size(); index++) {
WebElement webElement = webElements.get(index - 1);
String currentName = String.format("%1$s %2$s", namePrefix, index);
T element = supplier.get(generateLocator(locator, webElement, index), currentName, state);
list.add(element);
}
return list;
List<T> elements = new ArrayList<>();
Collection<Class<? extends Throwable>> ignoredExceptions = Arrays.asList(
StaleElementReferenceException.class, JavascriptException.class, org.openqa.selenium.TimeoutException.class
);
conditionalWait.waitFor(() -> {
List<WebElement> webElements = elementFinder.findElements(locator, state, ZERO_TIMEOUT);
for (int index = 1; index <= webElements.size(); index++) {
WebElement webElement = webElements.get(index - 1);
String currentName = String.format("%1$s %2$s", namePrefix, index);
T element = supplier.get(generateLocator(locator, webElement, index), currentName, state);
elements.add(element);
}
boolean anyElementsFound = !elements.isEmpty();
return count == ElementsCount.ANY
|| (count == ElementsCount.ZERO && !anyElementsFound)
|| (count == ElementsCount.MORE_THAN_ZERO && anyElementsFound);
}, ignoredExceptions);

return elements;
}

protected void waitForElementsCount(By locator, ElementsCount count, ElementState state) throws TimeoutException {
Expand Down
Loading