Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,28 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.6.0-jre</version>
<version>33.7.1-jre</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.22.2</version>
<version>2.22.3</version>
Comment thread
mialeska marked this conversation as resolved.
Resolved
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.49.0</version>
<version>4.50.0</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>10.1.1</version>
<version>11.0.0</version>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.20.0</version>
<version>3.21.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package aquality.selenium.core.applications;

import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.WebDriver;

import java.time.Duration;

Expand All @@ -12,7 +12,7 @@ public interface IApplication {
/**
* @return Current instance of driver.
*/
RemoteWebDriver getDriver();
WebDriver getDriver();

/**
* @return Is the application already running or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.function.Predicate;

/**
* Provides functions to retrive the state for cached element.
* Provides functions to retrieve the state for cached element.
*/
public class CachedElementStateProvider extends ElementStateProvider {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/aquality/selenium/core/elements/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.WebElement;

import java.time.Duration;
import java.util.List;
Expand Down Expand Up @@ -104,11 +104,11 @@ public IVisualStateProvider visual() {
}

@Override
public RemoteWebElement getElement(Duration timeout) {
public WebElement getElement(Duration timeout) {
try {
return getElementCacheConfiguration().isEnabled()
? getCache().getElement(timeout)
: (RemoteWebElement) getElementFinder().findElement(locator, elementState, timeout);
: getElementFinder().findElement(locator, elementState, timeout);
} catch (NoSuchElementException e) {
if (getLoggerConfiguration().logPageSource()) {
logPageSource(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import aquality.selenium.core.elements.interfaces.IElementCacheHandler;
import aquality.selenium.core.elements.interfaces.IElementFinder;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.WebElement;

import java.time.Duration;

Expand All @@ -16,7 +16,7 @@ public class ElementCacheHandler implements IElementCacheHandler {
private final ElementState state;
private final IElementFinder finder;

private RemoteWebElement remoteElement;
private WebElement remoteElement;

public ElementCacheHandler(By locator, ElementState state, IElementFinder finder) {
this.locator = locator;
Expand Down Expand Up @@ -46,10 +46,10 @@ public boolean wasCached() {
}

@Override
public RemoteWebElement getElement(Duration timeout, ElementState customState) {
public WebElement getElement(Duration timeout, ElementState customState) {
ElementState requiredState = customState == null ? state : customState;
if (isRefreshNeeded(requiredState)) {
remoteElement = (RemoteWebElement) finder.findElement(locator, requiredState, timeout);
remoteElement = finder.findElement(locator, requiredState, timeout);
}

return remoteElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import aquality.selenium.core.visualization.IVisualStateProvider;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.WebElement;

import java.time.Duration;

Expand Down Expand Up @@ -39,9 +39,9 @@ public interface IElement extends IParent {
* Default timeout is provided in {@link aquality.selenium.core.configurations.ITimeoutConfiguration}
* {@link org.openqa.selenium.NoSuchElementException} throws if element not found
*
* @return instance of {@link RemoteWebElement} if found.
* @return instance of {@link WebElement} if found.
*/
default RemoteWebElement getElement() {
default WebElement getElement() {
return getElement(null);
}

Expand All @@ -50,9 +50,9 @@ default RemoteWebElement getElement() {
* {@link org.openqa.selenium.NoSuchElementException} throws if element not found
*
* @param timeout Timeout for waiting
* @return instance of {@link RemoteWebElement} if found.
* @return instance of {@link WebElement} if found.
*/
RemoteWebElement getElement(Duration timeout);
WebElement getElement(Duration timeout);

/**
* Gets the item text (inner text).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package aquality.selenium.core.elements.interfaces;

import aquality.selenium.core.elements.ElementState;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.WebElement;

import java.time.Duration;

Expand All @@ -22,7 +22,7 @@ default boolean isRefreshNeeded() {
/**
* Determines is the cached element refresh needed.
*
* @param customState custom element's existance state used for search.
* @param customState custom element's existence state used for search.
* @return true if the refresh is needed (element wasn't found previously or is stale), false otherwise.
*/
boolean isRefreshNeeded(ElementState customState);
Expand All @@ -46,29 +46,29 @@ default boolean isStale() {
/**
* Allows to get cached element.
*
* @param timeout timeout used to retrive the element when {@link #isRefreshNeeded()} is true.
* @param customState custom element's existance state used for search.
* @param timeout timeout used to retrieve the element when {@link #isRefreshNeeded()} is true.
* @param customState custom element's existence state used for search.
* @return cached element.
*/
RemoteWebElement getElement(Duration timeout, ElementState customState);
WebElement getElement(Duration timeout, ElementState customState);

/**
* Allows to get cached element.
*
* @param timeout timeout used to retrive the element when {@link #isRefreshNeeded()} is true.
* @param timeout timeout used to retrieve the element when {@link #isRefreshNeeded()} is true.
* @return cached element.
*/
default RemoteWebElement getElement(Duration timeout) {
default WebElement getElement(Duration timeout) {
return getElement(timeout, null);
}

/**
* Allows to get cached element.
*
* @param customState custom element's existance state used for search.
* @param customState custom element's existence state used for search.
* @return cached element.
*/
default RemoteWebElement getElement(ElementState customState) {
default WebElement getElement(ElementState customState) {
return getElement(null, customState);
}

Expand All @@ -77,7 +77,7 @@ default RemoteWebElement getElement(ElementState customState) {
*
* @return cached element.
*/
default RemoteWebElement getElement() {
default WebElement getElement() {
return getElement(null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import aquality.selenium.core.elements.interfaces.IElement;
import aquality.selenium.core.logging.Logger;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.WebElement;

import javax.imageio.ImageIO;
import java.awt.*;
Expand Down Expand Up @@ -52,7 +52,7 @@ public static BufferedImage getScreenshotAsImage(IElement element) {
* @param element given element.
* @return image object.
*/
public static BufferedImage getScreenshotAsImage(RemoteWebElement element) {
public static BufferedImage getScreenshotAsImage(WebElement element) {
byte[] bytes = element.getScreenshotAs(OutputType.BYTES);
try (InputStream is = new ByteArrayInputStream(bytes)) {
return ImageIO.read(is);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import aquality.selenium.core.logging.ILogVisualState;
import aquality.selenium.core.utilities.IElementActionRetrier;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.WebElement;

import java.awt.*;
import java.awt.image.BufferedImage;
Expand All @@ -12,10 +12,10 @@
public class VisualStateProvider implements IVisualStateProvider {
private final IImageComparator imageComparator;
private final IElementActionRetrier actionRetrier;
private final Supplier<RemoteWebElement> getElement;
private final Supplier<WebElement> getElement;
private final ILogVisualState stateLogger;

public VisualStateProvider(IImageComparator imageComparator, IElementActionRetrier actionRetrier, Supplier<RemoteWebElement> getElement, ILogVisualState stateLogger){
public VisualStateProvider(IImageComparator imageComparator, IElementActionRetrier actionRetrier, Supplier<WebElement> getElement, ILogVisualState stateLogger){
this.imageComparator = imageComparator;
this.actionRetrier = actionRetrier;
this.getElement = getElement;
Expand Down Expand Up @@ -70,7 +70,7 @@ public float getDifference(Image theOtherOne) {
return value;
}

private <T> T getLoggedValue(String name, Function<RemoteWebElement, T> getValue, Function<T, String> toString) {
private <T> T getLoggedValue(String name, Function<WebElement, T> getValue, Function<T, String> toString) {
stateLogger.logVisualState("loc.el.visual.get" + name);
T value = actionRetrier.doWithRetry(() -> getValue.apply(getElement.get()));
String stringValue = toString == null ? getStringValue(value) : toString.apply(value);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/tests/applications/ICachedElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import aquality.selenium.core.elements.interfaces.IElementCacheHandler;
import aquality.selenium.core.elements.interfaces.IElementFinder;
import aquality.selenium.core.elements.interfaces.IElementStateProvider;
import aquality.selenium.core.logging.ILogElementState;
import aquality.selenium.core.localization.ILocalizationManager;
import aquality.selenium.core.localization.ILocalizedLogger;
import aquality.selenium.core.logging.ILogElementState;
import aquality.selenium.core.waitings.IConditionalWait;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.WebElement;

public interface ICachedElement {

Expand All @@ -32,7 +32,7 @@ default IElementCacheHandler cache() {
return getElementCacheHandler();
}

default RemoteWebElement getElement() {
default WebElement getElement() {
return cache().getElement();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tests.applications.browser;

import aquality.selenium.core.applications.IApplication;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
Expand All @@ -17,7 +18,7 @@ public class ChromeApplication implements IApplication {
}

@Override
public RemoteWebDriver getDriver() {
public WebDriver getDriver() {
return driver;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import aquality.selenium.core.applications.IApplication;
import io.appium.java_client.windows.WindowsDriver;
import io.appium.java_client.windows.options.WindowsOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.WebDriver;

import java.net.URL;
import java.time.Duration;
Expand All @@ -20,7 +20,7 @@ public class WindowsApplication implements IApplication {
}

@Override
public RemoteWebDriver getDriver() {
public WebDriver getDriver() {
return driver;
}

Expand Down
9 changes: 5 additions & 4 deletions src/test/java/tests/elements/CachedWebElementTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import aquality.selenium.core.elements.interfaces.IElementStateProvider;
import aquality.selenium.core.waitings.IConditionalWait;
import org.openqa.selenium.remote.RemoteWebElement;
import org.testng.Assert;
import org.testng.annotations.Test;
import tests.applications.browser.AqualityServices;
Expand Down Expand Up @@ -61,17 +62,17 @@ public void testShouldBeStaleWhenBecameInvisible() {
Assert.assertFalse(loader.state().isExist(),
"Loader that was displayed previously and become invisible should be treated as disappeared");
Assert.assertTrue(loader.state().waitForExist(ZERO_TIMEOUT),
"When waiting for existance, we should get an actual element's state");
"When waiting for existence, we should get an actual element's state");
}

@Test
public void testShouldRefreshElementWhenItIsStale() {
openDynamicControls();
CachedLabel example = DynamicControlsForm.getContentCachedLabel();
String exampleToString = example.getElement().getId();
String exampleToString = ((RemoteWebElement)example.getElement()).getId();
getBrowser().getDriver().navigate().refresh();
Assert.assertTrue(example.cache().isRefreshNeeded(), "refresh should be needed when refreshed the page");
String newToString = example.getElement().getId();
String newToString = ((RemoteWebElement)example.getElement()).getId();
Assert.assertNotEquals(newToString, exampleToString, "new and old element's IDs should be different");
}

Expand All @@ -80,7 +81,7 @@ public void testShouldReturnCorrectStateFalseWhenWindowIsRefreshed(Predicate<IEl
assertStateConditionAfterRefresh(stateCondition, false);
}

@Test(dataProvider = "stateFunctionsTrueWhenElementStaleWhichRetriveElement")
@Test(dataProvider = "stateFunctionsTrueWhenElementStaleWhichRetrieveElement")
public void testShouldReturnCorrectStateTrueWhenWindowIsRefreshed(Predicate<IElementStateProvider> stateCondition) throws TimeoutException {
assertStateConditionAfterRefresh(stateCondition, true);
}
Expand Down
Loading
Loading