From 37cafcf8ef83ee90c761ba0aac41ef0b60a35064 Mon Sep 17 00:00:00 2001 From: Valery Yatsynovich Date: Mon, 15 Aug 2022 10:25:13 +0300 Subject: [PATCH] refactor: Deprecate Appium `ByAll` Appium `io.appium.java_client.pagefactory.bys.builder.ByAll` was implemented as an extension of Selenium `org.openqa.selenium.support.pagefactory.ByAll` and introduced a performance improvement: "By All was re-implemented, now it returns the first founded element for single search." (https://github.com/appium/java-client/pull/686 on 3 Aug 2017). However Selenium team introduced the same performance fix "https://github.com/SeleniumHQ/selenium/commit/18028ac9f065b81fbe99a9e84feabfa5d0091f13 ByAll.findElement should not not use remaining locators if an element is already found" on 7 Sep 2017. So there is no reason to keep Appium `ByAll`, this commit deprecates it. --- .../pagefactory/DefaultElementByBuilder.java | 2 +- .../pagefactory/bys/builder/AppiumByBuilder.java | 1 + .../pagefactory/bys/builder/ByAll.java | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java b/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java index 135c2f423..23445fcf8 100644 --- a/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java +++ b/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java @@ -23,7 +23,6 @@ import io.appium.java_client.pagefactory.bys.ContentMappedBy; import io.appium.java_client.pagefactory.bys.ContentType; import io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder; -import io.appium.java_client.pagefactory.bys.builder.ByAll; import io.appium.java_client.pagefactory.bys.builder.ByChained; import io.appium.java_client.pagefactory.bys.builder.HowToUseSelectors; import org.openqa.selenium.By; @@ -32,6 +31,7 @@ import org.openqa.selenium.support.FindAll; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; +import org.openqa.selenium.support.pagefactory.ByAll; import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; diff --git a/src/main/java/io/appium/java_client/pagefactory/bys/builder/AppiumByBuilder.java b/src/main/java/io/appium/java_client/pagefactory/bys/builder/AppiumByBuilder.java index 14db1767b..423645881 100644 --- a/src/main/java/io/appium/java_client/pagefactory/bys/builder/AppiumByBuilder.java +++ b/src/main/java/io/appium/java_client/pagefactory/bys/builder/AppiumByBuilder.java @@ -24,6 +24,7 @@ import org.openqa.selenium.By; import org.openqa.selenium.support.pagefactory.AbstractAnnotations; +import org.openqa.selenium.support.pagefactory.ByAll; import javax.annotation.Nullable; import java.lang.annotation.Annotation; diff --git a/src/main/java/io/appium/java_client/pagefactory/bys/builder/ByAll.java b/src/main/java/io/appium/java_client/pagefactory/bys/builder/ByAll.java index 7332fe389..59015ede7 100644 --- a/src/main/java/io/appium/java_client/pagefactory/bys/builder/ByAll.java +++ b/src/main/java/io/appium/java_client/pagefactory/bys/builder/ByAll.java @@ -13,7 +13,20 @@ import java.util.Optional; import java.util.function.Function; - +/** + * Mechanism used to locate elements within a document using a series of lookups. This class will + * find all DOM elements that matches any of the locators in sequence, e.g. + * + *
+ * driver.findElements(new ByAll(by1, by2))
+ * 
+ * + * will find all elements that match by1 and then all elements that match by2. + * This means that the list of elements returned may not be in document order. + * + * @deprecated Use {@link org.openqa.selenium.support.pagefactory.ByAll} + */ +@Deprecated public class ByAll extends org.openqa.selenium.support.pagefactory.ByAll { private final List bys;