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

SMP Release #32

Merged
merged 120 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
c17e866
general section work
Feb 17, 2023
6014852
Merge remote-tracking branch 'origin/main'
Feb 28, 2023
86c2835
new changes, tests
Mar 2, 2023
49cbbeb
Merge remote-tracking branch 'origin/main'
Mar 2, 2023
5bf899d
some changes, fixes and new tests
Mar 6, 2023
03492aa
new tests
Mar 6, 2023
7f8d07a
Some changes
Mar 10, 2023
73518fd
Update ProxyServer
Mar 27, 2023
93c7b8f
Add ChromeOptions argument
Mar 27, 2023
576995f
Merge remote-tracking branch 'origin/main' into smpInternal
Mar 28, 2023
66438c8
Fix issues after upgrade to latest BELLATRIX
Mar 28, 2023
1c82275
Merge branch 'main' into smpInternal
Mar 28, 2023
db5484e
Browser.WaitUntil() method added
Mar 28, 2023
b6e4129
fix issues with configs and scroll to visible
Mar 30, 2023
df46592
fix using
Mar 30, 2023
de47fea
Added new ProxyServer methods
Mar 30, 2023
cb785b6
Merge branch 'smpInternal' of https://github.com/AutomateThePlanet/BE…
Mar 30, 2023
8da6c99
Implement WaitForImagestToLoad method, enable toast notifications
Mar 31, 2023
1e9d5fe
Merge remote-tracking branch 'origin/smpInternal' into smpInternal
Mar 31, 2023
9116ec5
Add capability for unexpected popups
Apr 3, 2023
edaa7ef
fixed most of the tests and their structure
Apr 4, 2023
d8dc399
Merge remote-tracking branch 'origin/main' into smpInternal
Apr 4, 2023
9961aa1
ProxyServer().assertRequestNotMade() fix
Apr 11, 2023
f5ac204
add logging
Apr 11, 2023
6e64937
fix video plugin
Apr 12, 2023
b260083
fix duplicate dependencies
Apr 12, 2023
24996b6
Merge branch 'smpInternal' of https://github.com/AutomateThePlanet/BE…
Apr 13, 2023
89f5e27
added waitForRequest() method to the BrowserService
Apr 13, 2023
5d969df
remove scroll logging as it floods the output
Apr 18, 2023
6775f6d
Merge remote-tracking branch 'origin/smpInternal' into smpInternal
Apr 18, 2023
cd9ecf1
remove scroll logging as it floods the output, add tun test filter
Apr 19, 2023
a790e9a
added new tests
Apr 24, 2023
7349cba
ProxyServer get request/response object fix
Apr 25, 2023
4b69090
Merge branch 'smpInternal' of https://github.com/AutomateThePlanet/BE…
Apr 25, 2023
19b54cb
New waitForResponse method added
May 17, 2023
dfdd153
add validation method in checkbox component
May 17, 2023
227124b
Merge remote-tracking branch 'origin/smpInternal' into smpInternal
May 17, 2023
1d5b0ab
ValidateIsDisabled method refactored
May 17, 2023
0dacf5a
wait response method refactored
May 18, 2023
a891d0c
Merge branch 'smpInternal' of https://github.com/AutomateThePlanet/BE…
May 18, 2023
522e290
apply wait for dashboard page on all tests
May 26, 2023
eeee8d8
added list with HTTP successful statuses and edited validation for su…
May 30, 2023
0f69564
add style validations
Jun 27, 2023
40cbc84
add initial value for threadlocal values
Jun 29, 2023
0db2602
revert console logs coloring
Jun 30, 2023
5da7f51
add error handling
Jul 19, 2023
ddc028d
Merge branch 'wait-for-ajax-fix' into smpInternal
Jul 19, 2023
fc085ae
add image data logging
Aug 3, 2023
17408fb
Added ClipboardManager
Aug 3, 2023
2110eda
Merge branch 'smpInternal' of https://github.com/AutomateThePlanet/BE…
Aug 3, 2023
5b2a7b9
add error logging, improve screenshot plugin to inject image to html …
Aug 9, 2023
8801a5a
Merge remote-tracking branch 'origin/smpInternal' into smpInternal
Aug 9, 2023
7436ab2
enhance logging
Aug 9, 2023
7ea6674
fix fetching of similar requests
Aug 14, 2023
a83e785
webdrivermanager removed and selenium update
Aug 17, 2023
04eb4e7
Merge branch 'smpInternal' of https://github.com/AutomateThePlanet/BE…
Aug 17, 2023
c44df51
Package org.apache.hc.core5.net.URIBuilder update
Aug 17, 2023
833a10a
Added browser version for test purposes
Aug 18, 2023
9df4aa1
Added Chrome & Chromedriver for testing
Aug 18, 2023
11e1535
Chrome_Headless mode configuration fixes
Aug 18, 2023
e84b80b
fix set window size priorities
Aug 18, 2023
4ed21c4
Merge remote-tracking branch 'origin/smpInternal' into smpInternal
Aug 18, 2023
23c5f38
fix browser defaults to be read from config
Aug 21, 2023
da54efa
add logging
Aug 22, 2023
bdf4068
remove console coloring commands
Aug 22, 2023
412e888
change headless mode to old
Aug 24, 2023
afd8fdb
update Entites asserter to ignore non-existanf properties
Aug 25, 2023
d5af611
change screenshot strategy to simple
Aug 25, 2023
5ba8ffd
add clipboard retrieval via JS code
Sep 25, 2023
6eb4397
update driver prompt disable via capabilities
Sep 27, 2023
5fc20bb
remove unused usings
Sep 27, 2023
192ec57
refactor resizing
Oct 17, 2023
3f36be0
remove assert throw
Oct 19, 2023
8c9107c
add getParent method to the web components
Oct 20, 2023
b24cd00
add environment getter
Nov 2, 2023
0a32ee1
add file name to screenshot generated event
Nov 3, 2023
cf0d71a
fix double screenshot
Nov 3, 2023
b55243a
refactor retry logic
Nov 8, 2023
68778d0
enhance Proxy server logging
Nov 8, 2023
16a9b81
add console log methods in BrowserService
Nov 8, 2023
3e8b374
fix minor issues
Nov 9, 2023
194d593
add console logs assertion
Dec 11, 2023
f0ac1f0
add javascript service to base page
Dec 15, 2023
64c48ea
add logging in proxy server
Dec 20, 2023
0f96f57
update logging in Proxy server
Jan 8, 2024
a189e7c
add experimental logic
Jan 9, 2024
a9badfe
revert experiment
Jan 10, 2024
6035d05
add scroll methods in BrowserService
Jan 12, 2024
b90a854
add wait without exception throw
Jan 16, 2024
45adc35
add supported response type
Jan 16, 2024
5a7879b
add tryWait method to catch exception in case it happens
Jan 24, 2024
abd5d78
refactor waitForRequest
Jan 25, 2024
7b45350
refactor usage of logs
Jan 25, 2024
053f478
apply fix in wait
Jan 25, 2024
8442083
add try catch in notification toasts
Jan 26, 2024
6ef22d4
add try catch in wait for page load
Jan 26, 2024
a7bd1be
fix logic in wait for request in delete
Jan 29, 2024
4592319
Fix After method execution when @ParametereziedTest annotaion is used
Feb 1, 2024
79f8343
add clipboard method
Feb 2, 2024
c31c17d
add clipboard method
Feb 2, 2024
8e8ab0a
format BrowserService
Feb 9, 2024
f1aecde
fix whitespace
Feb 9, 2024
0a058ee
add methods for scroll to visible
Feb 13, 2024
acb2640
enable browser type set as env variable
Feb 15, 2024
12d2a02
fix brwoserService issue with unsupported browsers
Feb 15, 2024
f4dbe80
revert scroll behavior to instant
Feb 16, 2024
d93b41e
Improved logging in Selenium wait
Mar 1, 2024
5effd5b
refactor getDataObject method in ProxyServer
Mar 11, 2024
0b8d188
Merge branch 'main' into smpInternal
Mar 19, 2024
58d9cc7
Merge with latest main
Mar 22, 2024
7f2b985
Add afterClass method that is not static and can be overridden
Apr 15, 2024
d1b633d
add checkbox method overload
Apr 22, 2024
e074463
fix issue is Browser wait
May 14, 2024
f49d707
minor fix
May 27, 2024
54c56f6
Enable Chrome Emulation mode with predefined devices
May 31, 2024
563539f
fix browserLifecycle attribute readings
Jun 4, 2024
2271e8c
support method-level browser change
Jun 4, 2024
b7a90d1
fix pr comments
Jun 5, 2024
394c2ff
Merge remote-tracking branch 'refs/remotes/origin/main' into smpInternal
Jun 5, 2024
d2bc948
fix warning
Jun 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.appium.java_client.remote.MobileCapabilityType;
import lombok.SneakyThrows;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import solutions.bellatrix.android.configuration.AndroidSettings;
import solutions.bellatrix.android.configuration.GridSettings;
Expand All @@ -30,11 +29,10 @@

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import java.util.HashMap;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

public class DriverService {
private static final ThreadLocal<Boolean> DISPOSED;
Expand Down Expand Up @@ -84,7 +82,7 @@ public static AndroidDriver start(AppConfiguration configuration) {
driver = initializeDriverGridMode(gridSettings.get(), testName);
}

driver.manage().timeouts().implicitlyWait(androidSettings.getTimeoutSettings().getImplicitWaitTimeout(), TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(androidSettings.getTimeoutSettings().getImplicitWaitTimeout()));
WRAPPED_ANDROID_DRIVER.set(driver);
solutions.bellatrix.web.infrastructure.DriverService.setWrappedDriver(driver);
return driver;
Expand Down
17 changes: 2 additions & 15 deletions bellatrix.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<version>1.0</version>

<properties>
<selenium.version>4.8.1</selenium.version>
<selenium.version>4.11.0</selenium.version>
<appium.version>8.3.0</appium.version>
<testng.version>7.7.0</testng.version>
<junit.version>5.9.2</junit.version>
Expand Down Expand Up @@ -62,19 +62,16 @@
<groupId>software.amazon.awssdk</groupId>
<artifactId>textract</artifactId>
</dependency>

<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.7.1</version>
</dependency>

<dependency>
<groupId>com.mailslurp</groupId>
<artifactId>mailslurp-client-java</artifactId>
<version>15.17.1</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand All @@ -83,7 +80,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
<version>33.0.0-jre</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down Expand Up @@ -156,15 +153,5 @@
<version>${rest.assured.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-secrets</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,32 @@ private static <TEntity> List<Exception> assertAreEqualsInternal(TEntity expecte
try {
currentExpectedProperty = expectedObject.getClass().getMethod(currentRealProperty.getName());
} catch (NoSuchMethodException e) {
failedAssertions.add(e);
System.out.println(String.format("Property %s not found.", currentRealProperty));
// failedAssertions.add(e);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line

}

var exceptionMessage = "The property " + currentRealProperty.getName() + " of class " + realObject.getClass().getSimpleName() + " was not as expected.";

try {
if (currentRealProperty.getReturnType() == LocalDateTime.class) {
LocalDateTimeAssert.areEqual(
(LocalDateTime) currentExpectedProperty.invoke(expectedObject),
(LocalDateTime) currentRealProperty.invoke(realObject),
(LocalDateTime)currentExpectedProperty.invoke(expectedObject),
(LocalDateTime)currentRealProperty.invoke(realObject),
deltaType, deltaQuantity, exceptionMessage);
} else {
Assertions.assertEquals(
currentExpectedProperty.invoke(expectedObject),
currentRealProperty.invoke(realObject),
exceptionMessage);
}

} catch (Exception ex) {
}
catch (NoSuchMethodException nsm){
//ignore this case
}
catch (NullPointerException nsmex){
//ignore this case
}
catch (Exception ex) {
failedAssertions.add(ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
public final class ConfigurationService {
private static String environment;

public static String getEnvironment() {
return environment;
}

public static <T> T get(Class<T> configSection) {
T mappedObject = (T)new Object();
if (environment == null) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@ public static String getSecret(Supplier<String> getConfigValue) {
return System.getenv(configValue.replace("env_", ""));
}

if (configValue.startsWith("vault_")) {
return KeyVault.getSecret(configValue.replace("vault_", ""));
}

return configValue;
}

public static String getSecret(String name) {
if (KeyVault.isAvailable) {
return KeyVault.getSecret(name);
}

String environmentalVariable = System.getenv(name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
package solutions.bellatrix.core.plugins;

import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.*;

public final class PluginExecutionEngine {
private final static Set<Plugin> PLUGINS;
private final static LinkedHashSet<Plugin> PLUGINS;

static {
PLUGINS = new LinkedHashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

package solutions.bellatrix.core.plugins.junit;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.extension.ExtendWith;
import solutions.bellatrix.core.plugins.PluginExecutionEngine;
import solutions.bellatrix.core.plugins.TestResult;
Expand All @@ -28,6 +25,7 @@
import java.util.List;

@ExtendWith(TestResultWatcher.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class BaseTest extends UsesPlugins {
static final ThreadLocal<TestResult> CURRENT_TEST_RESULT = new ThreadLocal<>();
private static final ThreadLocal<Boolean> CONFIGURATION_EXECUTED = new ThreadLocal<>();
Expand Down Expand Up @@ -92,7 +90,7 @@ public void afterMethodCore(TestInfo testInfo) {
try {
var testClass = this.getClass();
assert testInfo.getTestMethod().isPresent();
var methodInfo = testClass.getMethod(testInfo.getTestMethod().get().getName());
var methodInfo = testClass.getMethod(testInfo.getTestMethod().get().getName(), testInfo.getTestMethod().get().getParameterTypes());
PluginExecutionEngine.preAfterTest(CURRENT_TEST_RESULT.get(), methodInfo);
afterEach();
// PluginExecutionEngine.postAfterTest(CURRENT_TEST_RESULT.get(), methodInfo);
Expand All @@ -103,11 +101,12 @@ public void afterMethodCore(TestInfo testInfo) {
}

@AfterAll
public static void afterClassCore(TestInfo testInfo) {
public void afterClassCore(TestInfo testInfo) {
try {
var testClass = testInfo.getTestClass();
if (testClass.isPresent()) {
PluginExecutionEngine.preAfterClass(testClass.get());
afterClass();
PluginExecutionEngine.postAfterClass(testClass.get());
}
} catch (Exception e) {
Expand All @@ -134,4 +133,7 @@ protected void onBeforeEachFailure() {

protected void afterEach() {
}

protected void afterClass() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package solutions.bellatrix.core.utilities;

import java.awt.*;
import java.awt.datatransfer.*;
import java.io.IOException;

public class ClipboardManager {
private static final Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

public static String getLastEntity() {
var lastCopiedEntity = "";

try {
lastCopiedEntity = (String)systemClipboard.getData(DataFlavor.stringFlavor);
} catch (IOException | UnsupportedFlavorException e) {
throw new RuntimeException(e);
}

return lastCopiedEntity;
}

public static void copyTextToClipboard(String text) {
Transferable transferable = new StringSelection(text);
systemClipboard.setContents(transferable, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static <T> T getInstance(Class<T> classOf, Object... initargs) {

return (T)SINGLETON_FACTORY.mapHolder.get(classOf.getName());
} catch (Exception e) {
// not the best practice to return null. But probably we will never end here so it is OK.
Log.error("Failed to create instance of the object. Exception was: " + e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import java.time.Duration;

public class Wait {
public static void retry(Runnable action, int timesToRetry, long sleepInterval, Class<? extends Throwable> ... exceptionsToIgnore) throws InterruptedException {
public static void retry(Runnable action, int timesToRetry, long sleepInterval, Class<? extends Throwable> ... exceptionsToIgnore) {
Wait.retry(action, timesToRetry, sleepInterval, true, exceptionsToIgnore);
}

public static void retry(Runnable action, int timesToRetry, long sleepInterval,boolean shouldThrowException, Class<? extends Throwable> ... exceptionsToIgnore) {
int repeat = 0;
boolean shouldThrowException = true;
while(repeat <= timesToRetry) {
try {
shouldThrowException = true;
Expand All @@ -17,7 +20,11 @@ public static void retry(Runnable action, int timesToRetry, long sleepInterval,
//exc.printStackTrace();
repeat++;
shouldThrowException = false;
Thread.sleep(Duration.ofSeconds(sleepInterval).toMillis());
try {
Thread.sleep(Duration.ofSeconds(sleepInterval).toMillis());
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
break;
}
}
Expand All @@ -29,12 +36,11 @@ public static void retry(Runnable action, int timesToRetry, long sleepInterval,
}
}

public static void retry(Runnable action, Class<? extends Throwable> ... exceptionsToIgnore) throws InterruptedException {
public static void retry(Runnable action, Class<? extends Throwable> ... exceptionsToIgnore) {
retry(action, Duration.ofSeconds(30), Duration.ofSeconds(1), exceptionsToIgnore);
}

public static void retry(Runnable action, Duration timeout, Duration sleepInterval, Class<? extends Throwable> ... exceptionsToIgnore) throws InterruptedException {
boolean shouldThrowException = true;
public static boolean retry(Runnable action, Duration timeout, Duration sleepInterval, Boolean shouldThrowException, Class<? extends Throwable> ... exceptionsToIgnore) {
long start = System.currentTimeMillis();
long end = start + timeout.toMillis();
while(System.currentTimeMillis() < end) {
Expand All @@ -47,15 +53,28 @@ public static void retry(Runnable action, Duration timeout, Duration sleepInterv
if (currentException.isInstance(exc)) {
//exc.printStackTrace();
shouldThrowException = false;
Thread.sleep(sleepInterval.toMillis());
try {
Thread.sleep(sleepInterval.toMillis());
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
break;
}
}

if (shouldThrowException) {
throw exc;
}
else {
return false;
}
}
}

return true;
}

public static void retry(Runnable action, Duration timeout, Duration sleepInterval, Class<? extends Throwable> ... exceptionsToIgnore) {
Wait.retry(action, timeout, sleepInterval, true, exceptionsToIgnore);
}
}
Loading
Loading