Skip to content

Commit

Permalink
Bump org.seleniumhq.selenium:selenium-java from 4.22.0 to 4.23.0 (#1669)
Browse files Browse the repository at this point in the history
* Bump org.seleniumhq.selenium:selenium-java from 4.22.0 to 4.23.0

Bumps [org.seleniumhq.selenium:selenium-java](https://github.com/SeleniumHQ/selenium) from 4.22.0 to 4.23.0.
- [Release notes](https://github.com/SeleniumHQ/selenium/releases)
- [Commits](SeleniumHQ/selenium@selenium-4.22.0...selenium-4.23.0)

---
updated-dependencies:
- dependency-name: org.seleniumhq.selenium:selenium-java
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* fixing broken select tests

* optimizing assertion objects for multithreads

* fix mobile scrolling issue

* revert changes to test class

* use w3c standard platform names

* fix api validations to use threadlocal

* w3c compliant mobile: scripts

* w3c compliant mobile: scripts

* fix workflow params

* fix mobile os names

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mohab Mohie <[email protected]>
  • Loading branch information
dependabot[bot] and MohabMohie authored Jul 23, 2024
1 parent 33c5082 commit ec707d6
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 102 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/e2eTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
maven-version: 3.9.5
- name: Run tests
continue-on-error: true
run: mvn -e test "-DdefaultElementIdentificationTimeout=5" "-DretryMaximumNumberOfAttempts=2" "-DexecutionAddress=local" "-DtargetOperatingSystem=MAC" "-DtargetBrowserName=SAFARI" "-DgenerateAllureReportArchive=true" "-Dtest=${GLOBAL_TESTING_SCOPE}"
run: mvn -e test "-DdefaultElementIdentificationTimeout=5" "-DretryMaximumNumberOfAttempts=2" "-DexecutionAddress=local" "-DtargetOperatingSystem=MAC" "-DtargetBrowserName=safari" "-DgenerateAllureReportArchive=true" "-Dtest=${GLOBAL_TESTING_SCOPE}"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -378,7 +378,7 @@ jobs:
maven-version: 3.9.5
- name: Run tests
continue-on-error: true
run: mvn -e test "-DdefaultElementIdentificationTimeout=60" "-DretryMaximumNumberOfAttempts=2" "-DexecutionAddress=browserstack" "-DtargetOperatingSystem=ANDROID" "-Dmobile_automationName=UIAutomator2" "-DbrowserStack.platformVersion=13.0" "-DbrowserStack.deviceName=Google Pixel 7" "-DbrowserStack.appName=ApiDemos-debug.apk" "-DbrowserStack.appRelativeFilePath=src/test/resources/testDataFiles/apps/ApiDemos-debug.apk" "-DbrowserStack.appUrl=" "-DgenerateAllureReportArchive=true" "-Dtest=%regex[.*ndroidBasic.*]"
run: mvn -e test "-DdefaultElementIdentificationTimeout=60" "-DretryMaximumNumberOfAttempts=2" "-DexecutionAddress=browserstack" "-DtargetOperatingSystem=android" "-Dmobile_automationName=UIAutomator2" "-DbrowserStack.platformVersion=13.0" "-DbrowserStack.deviceName=Google Pixel 7" "-DbrowserStack.appName=ApiDemos-debug.apk" "-DbrowserStack.appRelativeFilePath=src/test/resources/testDataFiles/apps/ApiDemos-debug.apk" "-DbrowserStack.appUrl=" "-DgenerateAllureReportArchive=true" "-Dtest=%regex[.*ndroidBasic.*]"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -415,7 +415,7 @@ jobs:
maven-version: 3.9.5
- name: Run tests
continue-on-error: true
run: mvn -e test "-DdefaultElementIdentificationTimeout=5" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=browserstack" "-DtargetOperatingSystem=IOS" "-Dmobile_automationName=XCuiTest" "-DbrowserStack.osVersion=16" "-DbrowserStack.deviceName=iPhone 14" "-Dmobile_browserName=SAFARI" "-DbrowserStack.appName=" "-DbrowserStack.appRelativeFilePath=" "-DbrowserStack.appUrl=" "-DgenerateAllureReportArchive=true" "-Dtest=%regex[.*MobileWebTest.*]"
run: mvn -e test "-DdefaultElementIdentificationTimeout=5" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=browserstack" "-DtargetOperatingSystem=iOS" "-Dmobile_automationName=XCuiTest" "-DbrowserStack.osVersion=16" "-DbrowserStack.deviceName=iPhone 14" "-Dmobile_browserName=safari" "-DbrowserStack.appName=" "-DbrowserStack.appRelativeFilePath=" "-DbrowserStack.appUrl=" "-DgenerateAllureReportArchive=true" "-Dtest=%regex[.*MobileWebTest.*]"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -452,7 +452,7 @@ jobs:
maven-version: 3.9.5
- name: Run tests
continue-on-error: true
run: mvn -e test "-DdefaultElementIdentificationTimeout=5" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=browserstack" "-DtargetOperatingSystem=ANDROID" "-Dmobile_automationName=UIAutomator2" "-DbrowserStack.osVersion=13.0" "-DbrowserStack.deviceName=Samsung Galaxy S23" "-Dmobile_browserName=CHROME" "-DbrowserStack.appName=" "-DbrowserStack.appRelativeFilePath=" "-DbrowserStack.appUrl=" "-DgenerateAllureReportArchive=true" "-Dtest=%regex[.*MobileWebTest.*]"
run: mvn -e test "-DdefaultElementIdentificationTimeout=5" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=browserstack" "-DtargetOperatingSystem=android" "-Dmobile_automationName=UIAutomator2" "-DbrowserStack.osVersion=13.0" "-DbrowserStack.deviceName=Samsung Galaxy S23" "-Dmobile_browserName=chrome" "-DbrowserStack.appName=" "-DbrowserStack.appRelativeFilePath=" "-DbrowserStack.appUrl=" "-DgenerateAllureReportArchive=true" "-Dtest=%regex[.*MobileWebTest.*]"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -489,7 +489,7 @@ jobs:
maven-version: 3.9.5
- name: Run tests
continue-on-error: true
run: mvn -e test "-DdefaultElementIdentificationTimeout=5" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=browserstack" "-DtargetOperatingSystem=ANDROID" "-Dmobile_automationName=UIAutomator2" "-DbrowserStack.osVersion=13.0" "-DbrowserStack.deviceName=Samsung Galaxy S23" "-Dmobile_browserName=samsung" "-DbrowserStack.appName=" "-DbrowserStack.appRelativeFilePath=" "-DbrowserStack.appUrl=" "-DgenerateAllureReportArchive=true" "-Dtest=%regex[.*MobileWebTest.*]"
run: mvn -e test "-DdefaultElementIdentificationTimeout=5" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=browserstack" "-DtargetOperatingSystem=android" "-Dmobile_automationName=UIAutomator2" "-DbrowserStack.osVersion=13.0" "-DbrowserStack.deviceName=Samsung Galaxy S23" "-Dmobile_browserName=samsung" "-DbrowserStack.appName=" "-DbrowserStack.appRelativeFilePath=" "-DbrowserStack.appUrl=" "-DgenerateAllureReportArchive=true" "-Dtest=%regex[.*MobileWebTest.*]"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.22.0</version>
<version>4.23.0</version>
</dependency>

<!-- APPIUM -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.Browser;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;

import java.time.Duration;
import java.util.ArrayList;
Expand All @@ -18,11 +17,11 @@ public SynchronizationManager(WebDriver driver) {
this.driver = driver;
}

public Wait<?> fluentWait() {
public FluentWait<?> fluentWait() {
return fluentWait(false);
}

public Wait<?> fluentWait(boolean isValidToCheckForVisibility) {
public FluentWait<?> fluentWait(boolean isValidToCheckForVisibility) {
return new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds((long) (SHAFT.Properties.timeouts.defaultElementIdentificationTimeout())))
.pollingEvery(Duration.ofMillis(ELEMENT_IDENTIFICATION_POLLING_DELAY))
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/shaft/gui/element/TouchActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ public TouchActions swipeElementIntoView(By scrollableElementLocator, By targetE
}
}
elementActionsHelper.passAction(driverFactoryHelper.getDriver(), targetElementLocator, Thread.currentThread().getStackTrace()[1].getMethodName(), null, null, null);
} catch (UnsupportedCommandException unsupportedCommandException) {
throw unsupportedCommandException;
} catch (Exception e) {
elementActionsHelper.failAction(driverFactoryHelper.getDriver(), targetElementLocator, e);
}
Expand Down Expand Up @@ -735,13 +737,13 @@ private boolean attemptW3cCompliantActionsScroll(SwipeDirection swipeDirection,
scrollParameters.putAll(ImmutableMap.of(
"direction", swipeDirection.toString()
));
canScrollMore = (Boolean) ((JavascriptExecutor) androidDriver).executeScript("scrollGesture", scrollParameters);
canScrollMore = (Boolean) androidDriver.executeScript("mobile:scrollGesture", scrollParameters);
} else if (driverFactoryHelper.getDriver() instanceof IOSDriver iosDriver) {
scrollParameters.putAll(ImmutableMap.of(
"direction", swipeDirection.toString()
));
//http://appium.github.io/appium-xcuitest-driver/4.16/execute-methods/#mobile-scroll
var ret = ((JavascriptExecutor) iosDriver).executeScript("scroll", scrollParameters);
var ret = iosDriver.executeScript("mobile:scroll", scrollParameters);
canScrollMore = ret == null || (Boolean) ret;
}
var logMessageAfter = "Attempted to scroll using these parameters: \"" + scrollParameters + "\"";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

@SuppressWarnings({"UnusedReturnValue"})
public class ElementActionsHelper {
Expand All @@ -51,18 +52,18 @@ public ElementActionsHelper(boolean isSilent) {
}

public int waitForElementPresenceWithReducedTimeout(WebDriver driver, By elementLocator) {
var defaultElementIdentificationTimeout = SHAFT.Properties.timeouts.defaultElementIdentificationTimeout();
SHAFT.Properties.timeouts.set().defaultElementIdentificationTimeout(0.3); //this is used for faster mobile native scrolling. default for ios is 200 and for android is 250, this covers both
List<Object> numberOfFoundElements;
AtomicInteger numberOfFoundElements = new AtomicInteger();
try {
numberOfFoundElements = waitForElementPresence(driver, elementLocator);
} catch (Throwable throwable) {
// in case the element was not found, reset the timeouts
SHAFT.Properties.timeouts.set().defaultElementIdentificationTimeout(defaultElementIdentificationTimeout);
throw throwable;
new SynchronizationManager(driver).fluentWait(true)
.withTimeout(Duration.ofMillis(300)) //this is used for faster mobile native scrolling. default for ios is 200 and for android is 250, this covers both
.until(f -> {
numberOfFoundElements.set(driver.findElements(elementLocator).size());
return numberOfFoundElements.get() > 0;
});
} catch (TimeoutException timeoutException) {
return 0;
}
SHAFT.Properties.timeouts.set().defaultElementIdentificationTimeout(defaultElementIdentificationTimeout);
return Integer.parseInt(numberOfFoundElements.getFirst().toString());
return numberOfFoundElements.get();
}

public List<Object> waitForElementPresence(WebDriver driver, By elementLocator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ValidationsExecutor {
private final String validationMethod;
@SuppressWarnings({"FieldCanBeLocal", "unused"})
private String validationCategoryString;
private WebDriver driver;
private final ThreadLocal<WebDriver> driver = new ThreadLocal<>();
private By locator;
private String customReportMessage = "";
private ValidationEnums.VisualValidationEngine visualValidationEngine;
Expand All @@ -34,7 +34,7 @@ public class ValidationsExecutor {
private boolean condition;
private Object actualValue;
private ValidationEnums.NumbersComparativeRelation numbersComparativeRelation;
private Object response;
private final ThreadLocal<Object> response = new ThreadLocal<>();
private String fileAbsolutePath;
private RestActions.ComparisonType restComparisonType;
private String jsonPath;
Expand All @@ -43,7 +43,7 @@ public class ValidationsExecutor {

public ValidationsExecutor(WebDriverElementValidationsBuilder webDriverElementValidationsBuilder) {
this.validationCategory = webDriverElementValidationsBuilder.validationCategory;
this.driver = webDriverElementValidationsBuilder.driver;
this.driver.set(webDriverElementValidationsBuilder.driver);
this.locator = webDriverElementValidationsBuilder.locator;
this.validationType = webDriverElementValidationsBuilder.validationType;
this.validationMethod = webDriverElementValidationsBuilder.validationMethod;
Expand All @@ -53,7 +53,7 @@ public ValidationsExecutor(WebDriverElementValidationsBuilder webDriverElementVa

public ValidationsExecutor(NativeValidationsBuilder nativeValidationsBuilder) {
this.validationCategory = nativeValidationsBuilder.validationCategory;
this.driver = nativeValidationsBuilder.driver;
this.driver.set(nativeValidationsBuilder.driver);
this.locator = nativeValidationsBuilder.locator;
this.validationType = nativeValidationsBuilder.validationType;
this.validationMethod = nativeValidationsBuilder.validationMethod;
Expand All @@ -64,7 +64,7 @@ public ValidationsExecutor(NativeValidationsBuilder nativeValidationsBuilder) {
this.elementCssProperty = nativeValidationsBuilder.elementCssProperty;
this.browserAttribute = nativeValidationsBuilder.browserAttribute;

this.response = nativeValidationsBuilder.response;
this.response.set(nativeValidationsBuilder.response);
this.jsonPath = nativeValidationsBuilder.jsonPath;

this.folderRelativePath = nativeValidationsBuilder.folderRelativePath;
Expand Down Expand Up @@ -94,7 +94,7 @@ public ValidationsExecutor(NumberValidationsBuilder numberValidationsBuilder) {

this.numbersComparativeRelation = numberValidationsBuilder.numbersComparativeRelation;

this.response = numberValidationsBuilder.response;
this.response.set(numberValidationsBuilder.response);
this.jsonPath = numberValidationsBuilder.jsonPath;

this.reportMessageBuilder = numberValidationsBuilder.reportMessageBuilder;
Expand All @@ -105,7 +105,7 @@ public ValidationsExecutor(RestValidationsBuilder restValidationsBuilder) {
this.validationCategory = restValidationsBuilder.validationCategory;
this.validationMethod = restValidationsBuilder.validationMethod;
this.validationType = restValidationsBuilder.validationType;
this.response = restValidationsBuilder.response;
this.response.set(restValidationsBuilder.response);
this.fileAbsolutePath = restValidationsBuilder.fileAbsolutePath;
this.restComparisonType = restValidationsBuilder.restComparisonType;

Expand Down Expand Up @@ -141,7 +141,7 @@ public void perform() {
}

protected void internalPerform() {
JavaScriptWaitManager.waitForLazyLoading(driver);
JavaScriptWaitManager.waitForLazyLoading(driver.get());
boolean clearCustomReportMessage = false;
if (customReportMessage.isBlank()) {
customReportMessage = reportMessageBuilder.toString();
Expand All @@ -155,6 +155,8 @@ protected void internalPerform() {
}
if (Boolean.TRUE.equals(clearCustomReportMessage))
customReportMessage = "";
driver.remove();
response.remove();
}

@Step(" {this.validationCategoryString} that {this.customReportMessage}")
Expand All @@ -166,34 +168,34 @@ private void performValidation() {
case "conditionIsTrue" ->
new ValidationsHelper().validateTrue(validationCategory, condition, validationType, customReportMessage);
case "elementExists" ->
new ValidationsHelper2(validationCategory).validateElementExists(driver, locator, validationType);
new ValidationsHelper2(validationCategory).validateElementExists(driver.get(), locator, validationType);
case "elementMatches" ->
new ValidationsHelper().validateElementMatches(validationCategory, driver, locator, visualValidationEngine, validationType, customReportMessage);
new ValidationsHelper().validateElementMatches(validationCategory, driver.get(), locator, visualValidationEngine, validationType, customReportMessage);
case "elementAttributeEquals" ->
new ValidationsHelper2(validationCategory).validateElementAttribute(driver, locator, elementAttribute, String.valueOf(expectedValue), validationComparisonType, validationType);
new ValidationsHelper2(validationCategory).validateElementAttribute(driver.get(), locator, elementAttribute, String.valueOf(expectedValue), validationComparisonType, validationType);
case "elementCssPropertyEquals" ->
new ValidationsHelper2(validationCategory).validateElementCSSProperty(driver, locator, elementCssProperty, String.valueOf(expectedValue), validationComparisonType, validationType);
new ValidationsHelper2(validationCategory).validateElementCSSProperty(driver.get(), locator, elementCssProperty, String.valueOf(expectedValue), validationComparisonType, validationType);
case "browserAttributeEquals" ->
new ValidationsHelper2(validationCategory).validateBrowserAttribute(driver, browserAttribute, String.valueOf(expectedValue), validationComparisonType, validationType);
new ValidationsHelper2(validationCategory).validateBrowserAttribute(driver.get(), browserAttribute, String.valueOf(expectedValue), validationComparisonType, validationType);
case "comparativeRelationBetweenNumbers" ->
new ValidationsHelper2(validationCategory).validateNumber((Number) expectedValue, (Number) actualValue, numbersComparativeRelation, validationType);
case "fileExists" ->
new ValidationsHelper().validateFileExists(validationCategory, folderRelativePath, fileName, 5, validationType, customReportMessage);
case "responseEqualsFileContent" ->
new ValidationsHelper().validateJSONFileContent(validationCategory, (Response) response, fileAbsolutePath, restComparisonType, "", validationType, customReportMessage);
new ValidationsHelper().validateJSONFileContent(validationCategory, (Response) response.get(), fileAbsolutePath, restComparisonType, "", validationType, customReportMessage);
case "jsonPathValueEquals" ->
new ValidationsHelper2(validationCategory).validateEquals(expectedValue, RestActions.getResponseJSONValue(response, jsonPath), validationComparisonType, validationType);
new ValidationsHelper2(validationCategory).validateEquals(expectedValue, RestActions.getResponseJSONValue(response.get(), jsonPath), validationComparisonType, validationType);
case "jsonPathValueAsListEquals" -> {
for (Object value : Objects.requireNonNull(RestActions.getResponseJSONValueAsList((Response) response, jsonPath))) {
for (Object value : Objects.requireNonNull(RestActions.getResponseJSONValueAsList((Response) response.get(), jsonPath))) {
new ValidationsHelper2(validationCategory).validateEquals(expectedValue, value.toString(), validationComparisonType, validationType);
}
}
case "responseBody" ->
new ValidationsHelper2(validationCategory).validateEquals(expectedValue, RestActions.getResponseBody((Response) response), validationComparisonType, validationType);
new ValidationsHelper2(validationCategory).validateEquals(expectedValue, RestActions.getResponseBody((Response) response.get()), validationComparisonType, validationType);
case "responseTime" ->
new ValidationsHelper2(validationCategory).validateNumber((Number) expectedValue, RestActions.getResponseTime((Response) response), numbersComparativeRelation, validationType);
new ValidationsHelper2(validationCategory).validateNumber((Number) expectedValue, RestActions.getResponseTime((Response) response.get()), numbersComparativeRelation, validationType);
case "checkResponseSchema" ->
new ValidationsHelper().validateResponseFileSchema(validationCategory, (Response) response, fileAbsolutePath, restComparisonType, "", validationType, customReportMessage);
new ValidationsHelper().validateResponseFileSchema(validationCategory, (Response) response.get(), fileAbsolutePath, restComparisonType, "", validationType, customReportMessage);
case "fileContent" -> {
String fileContent;
if (fileName.contains(".pdf")) {
Expand Down
Loading

0 comments on commit ec707d6

Please sign in to comment.