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
8 changes: 1 addition & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ dependencies {
if (seleniumVersion.toString().contains('SNAPSHOT')) {
api "org.seleniumhq.selenium:selenium-api:${seleniumVersion}"
api "org.seleniumhq.selenium:selenium-remote-driver:${seleniumVersion}"
api "org.seleniumhq.selenium:selenium-support:${seleniumVersion}"
} else {
api('org.seleniumhq.selenium:selenium-api') {
version {
Expand All @@ -81,12 +80,6 @@ dependencies {
prefer "${seleniumVersion}"
}
}
api('org.seleniumhq.selenium:selenium-support') {
version {
strictly "[${seleniumVersion}, 5.0)"
prefer "${seleniumVersion}"
}
}
}
implementation 'com.google.code.gson:gson:2.14.0'
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
Expand Down Expand Up @@ -226,6 +219,7 @@ testing {
implementation 'org.junit.jupiter:junit-jupiter:5.14.4'
runtimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.hamcrest:hamcrest:3.0'
implementation "org.seleniumhq.selenium:selenium-support:${seleniumVersion}"
runtimeOnly "org.slf4j:slf4j-simple:${slf4jVersion}"
}
targets.configureEach {
Expand Down
3 changes: 3 additions & 0 deletions config/checkstyle/appium-style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="AvoidStarImport"/>
<module name="ImportControl">
<property name="file" value="${config_loc}/import-control.xml"/>
</module>
<module name="CustomImportOrder">
<property name="customImportOrderRules" value="THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE###STATIC"/>
<property name="specialImportsRegExp" value="^javax\."/>
Expand Down
22 changes: 22 additions & 0 deletions config/checkstyle/import-control.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE import-control PUBLIC
"-//Checkstyle//DTD ImportControl Configuration 1.4//EN"
"https://checkstyle.org/dtds/import_control_1_4.dtd">
<!--
The io.appium.java_client.support package tree is a self-contained page factory and wait engine,
kept free of the rest of java-client so that it can be extracted into its own module later.
It may only depend on selenium-api, jspecify and the JDK.
-->
<import-control pkg="io.appium.java_client" strategyOnMismatch="allowed">
<subpackage name="support" strategyOnMismatch="disallowed">
<allow pkg="io.appium.java_client.support"/>
<disallow pkg="org.openqa.selenium.remote"/>
<disallow pkg="org.openqa.selenium.support"/>
<disallow pkg="org.openqa.selenium.json"/>
<disallow pkg="org.openqa.selenium.os"/>
<disallow pkg="org.openqa.selenium.bidi"/>
<allow pkg="org.openqa.selenium"/>
<allow pkg="org.jspecify"/>
<allow pkg="java"/>
</subpackage>
</import-control>
1 change: 1 addition & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks="MissingJavadocMethod" files="(.*Test(s)?|/TestUtils|/EmptyWebDriver).java" />
<suppress checks="ImportControl" files="[\\/]src[\\/](test|e2e[A-Za-z]*)[\\/]" />
</suppressions>
47 changes: 28 additions & 19 deletions docs/Page-objects.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
Appium Java client has facilities which components to [Page Object](https://github.com/SeleniumHQ/selenium/wiki/PageObjects) design pattern and [Selenium PageFactory](https://github.com/SeleniumHQ/selenium/wiki/PageFactory).

> **Migrating from Selenium's page factory**: `@FindBy`, `@FindBys`, `@FindAll`, `@CacheLookup`, `PageFactory` and
> the related classes are now provided by the `io.appium.java_client.support` package (same names and attributes as
> `org.openqa.selenium.support`), because Appium Java Client does not depend on `selenium-support` anymore.
> Replace the `org.openqa.selenium.support` imports with `io.appium.java_client.support` ones.
> Page objects that still use Selenium's `@FindBy`, `@FindBys`, `@FindAll` and `@CacheLookup` keep working with
> `AppiumFieldDecorator` as long as `selenium-support` is on your classpath.
> `PageFactory.initElements(driver, page)` shortcuts that rely on Selenium's own decorator are not provided,
> use `PageFactory.initElements(new AppiumFieldDecorator(driver), page)` instead.


# WebElement/list of WebElement field can be populated by default:
```java
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import io.appium.java_client.support.FindBy;
...

@FindBy(someStrategy) //for browser or web view html UI
Expand Down Expand Up @@ -62,7 +71,7 @@ List<WebElement> someElements;
```java
import org.openqa.selenium.remote.RemoteWebElement;
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.FindBy;
import io.appium.java_client.support.FindBy;

//the fully cross platform example
@FindBy(someStrategy) //for browser or web view html UI
Expand All @@ -84,8 +93,8 @@ List<RemoteWebElement> someElements;
```java
import org.openqa.selenium.remote.RemoteWebElement;
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.FindBys;
import org.openqa.selenium.support.FindBy;
import io.appium.java_client.support.FindBys;
import io.appium.java_client.support.FindBy;

@FindBys({@FindBy(someStrategy1), @FindBy(someStrategy2)})
@AndroidFindBy(someStrategy1) @AndroidFindBy(someStrategy2)
Expand All @@ -103,8 +112,8 @@ or
```java
import org.openqa.selenium.remote.RemoteWebElement;
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.FindBys;
import org.openqa.selenium.support.FindBy;
import io.appium.java_client.support.FindBys;
import io.appium.java_client.support.FindBy;

import static io.appium.java_client.pagefactory.LocatorGroupStrategy.CHAIN;

Expand All @@ -126,8 +135,8 @@ List<RemoteWebElement> someElements;
```java
import org.openqa.selenium.remote.RemoteWebElement;
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.FindByAll;
import io.appium.java_client.support.FindBy;
import io.appium.java_client.support.FindAll;

import static io.appium.java_client.pagefactory.LocatorGroupStrategy.ALL_POSSIBLE;

Expand All @@ -149,8 +158,8 @@ List<RemoteWebElement> someElements;
```java
import org.openqa.selenium.remote.RemoteWebElement;
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.FindByAll;
import io.appium.java_client.support.FindBy;
import io.appium.java_client.support.FindAll;

import static io.appium.java_client.pagefactory.LocatorGroupStrategy.CHAIN;
import static io.appium.java_client.pagefactory.LocatorGroupStrategy.ALL_POSSIBLE;
Expand All @@ -173,8 +182,8 @@ or
```java
import org.openqa.selenium.remote.RemoteWebElement;
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.FindByAll;
import io.appium.java_client.support.FindBy;
import io.appium.java_client.support.FindAll;

import static io.appium.java_client.pagefactory.LocatorGroupStrategy.ALL_POSSIBLE;

Expand Down Expand Up @@ -203,8 +212,8 @@ If the using of _xpath_ is not convenient for some reasons so there are possible
```java
import org.openqa.selenium.remote.RemoteWebElement;
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.FindBys;
import org.openqa.selenium.support.FindBy;
import io.appium.java_client.support.FindBys;
import io.appium.java_client.support.FindBy;

//it is necessary to define priorities at this case. The lower number means the higher priority.
//The default value is 0 (the highest priority)
Expand All @@ -229,8 +238,8 @@ List<RemoteWebElement> someElements;
```java
import org.openqa.selenium.remote.RemoteWebElement;
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.FindBys;
import org.openqa.selenium.support.FindBy;
import io.appium.java_client.support.FindBys;
import io.appium.java_client.support.FindBy;

//it is not necessary to define priorities at this case. But it can manage the searching.
//The lower number means the higher priority.
Expand Down Expand Up @@ -261,7 +270,7 @@ Object fields are populated as below:
-
```java
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.PageFactory;
import io.appium.java_client.support.PageFactory;

PageFactory.initElements(new AppiumFieldDecorator(searchContext
/*searchContext is a WebDriver or WebElement
Expand All @@ -273,7 +282,7 @@ PageFactory.initElements(new AppiumFieldDecorator(searchContext
-
```java
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.PageFactory;
import io.appium.java_client.support.PageFactory;
import java.util.concurrent.TimeUnit;

PageFactory.initElements(new AppiumFieldDecorator(searchContext,
Expand All @@ -288,7 +297,7 @@ PageFactory.initElements(new AppiumFieldDecorator(searchContext,
-
```java
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.PageFactory;
import io.appium.java_client.support.PageFactory;
import java.util.concurrent.TimeUnit;

PageFactory.initElements(new AppiumFieldDecorator(searchContext,
Expand Down
14 changes: 4 additions & 10 deletions docs/transitive-dependencies-management.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
> **Note**: Appium Java Client does not depend on `selenium-support` anymore. If your code uses its classes
> (`WebDriverWait`, `ExpectedConditions`, `Select`, `EventFiringDecorator`, etc.), declare it in your own
> build the same way as the other Selenium dependencies below.

# Maven

Maven downloads dependency of [the latest version](https://cwiki.apache.org/confluence/display/MAVENOLD/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges)
Expand All @@ -21,10 +25,6 @@ In order to pin Selenium dependencies they should be declared in `pom.xml` in th
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -37,11 +37,6 @@ In order to pin Selenium dependencies they should be declared in `pom.xml` in th
<artifactId>selenium-remote-driver</artifactId>
<version>A.B.C</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>A.B.C</version>
</dependency>
</dependencies>
```

Expand All @@ -63,6 +58,5 @@ dependencies {
implementation('io.appium:java-client:X.Y.Z')
implementation('org.seleniumhq.selenium:selenium-api:A.B.C')
implementation('org.seleniumhq.selenium:selenium-remote-driver:A.B.C')
implementation('org.seleniumhq.selenium:selenium-support:A.B.C')
}
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.appium.java_client.android;

import io.appium.java_client.functions.AppiumFunction;
import io.appium.java_client.functions.ExpectedCondition;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -104,7 +103,7 @@ public void complexWaitingTestWithPreCondition() {
};

AppiumFunction<Pattern, List<WebElement>> compositeFunction = waitingForContext
.andThen((ExpectedCondition<List<WebElement>>) input -> {
.andThen((AppiumFunction<WebDriver, List<WebElement>>) input -> {
List<WebElement> result = searchingFunction.apply(input);
if (result != null) {
calls.add(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import io.appium.java_client.remote.MobileBrowserType;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.support.FindBy;
import io.appium.java_client.support.PageFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
import io.appium.java_client.pagefactory.AndroidFindBys;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import io.appium.java_client.pagefactory.HowToUseLocators;
import io.appium.java_client.support.CacheLookup;
import io.appium.java_client.support.FindBy;
import io.appium.java_client.support.PageFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WrapsDriver;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

import java.util.ArrayList;
import java.util.HashSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import io.appium.java_client.remote.MobileBrowserType;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.support.FindBy;
import io.appium.java_client.support.FindBys;
import io.appium.java_client.support.PageFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.FindBys;
import org.openqa.selenium.support.PageFactory;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import io.appium.java_client.pagefactory.HowToUseLocators;
import io.appium.java_client.pagefactory.iOSXCUITFindBy;
import io.appium.java_client.support.PageFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;

import java.util.List;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/appium/java_client/AppiumFluentWait.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
package io.appium.java_client;

import com.google.common.base.Throwables;
import io.appium.java_client.support.ui.FluentWait;
import io.appium.java_client.support.ui.Sleeper;
import lombok.AccessLevel;
import lombok.Getter;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Sleeper;

import java.time.Clock;
import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* This is extended version of {@link com.google.common.base.Function}. It is combined
* with {@link java.util.function.Function}. It was designed in order to provide compatibility
* with the {@link org.openqa.selenium.support.ui.Wait}.
* with the {@link io.appium.java_client.support.ui.Wait}.
*
* @param <F> The input type
* @param <T> The return type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* Used to mark a field on a Page Object to indicate an alternative mechanism for locating the
* element or a list of elements. Used in conjunction with
* {@link org.openqa.selenium.support.PageFactory}
* {@link io.appium.java_client.support.PageFactory}
* this allows users to quickly and easily create PageObjects.
* using Android UI selectors, accessibility, id, name, class name, tag and xpath
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

import io.appium.java_client.pagefactory.bys.ContentMappedBy;
import io.appium.java_client.pagefactory.locator.CacheableLocator;
import io.appium.java_client.support.ui.FluentWait;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.FluentWait;

import java.lang.ref.WeakReference;
import java.time.Duration;
Expand Down
Loading
Loading