From 06bb4e9f331afe228c7512ae9649788cac03b54e Mon Sep 17 00:00:00 2001 From: joerg1985 <16140691+joerg1985@users.noreply.github.com> Date: Tue, 10 Oct 2023 22:15:51 +0200 Subject: [PATCH] [java] remove lift related packages and dependencies (#12917) --- Rakefile | 3 - java/maven_deps.bzl | 11 -- java/maven_install.json | 73 +------ java/src/org/openqa/selenium/grid/BUILD.bazel | 1 - java/src/org/openqa/selenium/lift/BUILD.bazel | 19 -- .../src/org/openqa/selenium/lift/Finders.java | 149 -------------- .../lift/HamcrestWebDriverTestCase.java | 145 -------------- .../org/openqa/selenium/lift/Matchers.java | 53 ----- .../org/openqa/selenium/lift/TestContext.java | 43 ---- .../selenium/lift/WebDriverTestContext.java | 154 --------------- .../openqa/selenium/lift/find/BaseFinder.java | 98 --------- .../openqa/selenium/lift/find/DivFinder.java | 44 ----- .../org/openqa/selenium/lift/find/Finder.java | 29 --- .../selenium/lift/find/HtmlTagFinder.java | 53 ----- .../selenium/lift/find/ImageFinder.java | 41 ---- .../selenium/lift/find/InputFinder.java | 65 ------ .../openqa/selenium/lift/find/LinkFinder.java | 50 ----- .../selenium/lift/find/PageTitleFinder.java | 50 ----- .../selenium/lift/find/TableCellFinder.java | 43 ---- .../selenium/lift/find/TableFinder.java | 43 ---- .../selenium/lift/find/XPathFinder.java | 44 ----- .../selenium/lift/match/AttributeMatcher.java | 52 ----- .../selenium/lift/match/DisplayedMatcher.java | 43 ---- .../lift/match/NumericalMatchers.java | 36 ---- .../selenium/lift/match/SelectionMatcher.java | 42 ---- .../selenium/lift/match/TextMatcher.java | 49 ----- .../selenium/lift/match/ValueMatcher.java | 48 ----- .../test/org/openqa/selenium/bidi/BUILD.bazel | 1 - .../selenium/bidi/browsingcontext/BUILD.bazel | 1 - .../org/openqa/selenium/bidi/log/BUILD.bazel | 1 - .../org/openqa/selenium/devtools/BUILD.bazel | 1 - .../test/org/openqa/selenium/lift/BUILD.bazel | 17 -- .../lift/HamcrestWebdriverTestCaseTest.java | 91 --------- .../openqa/selenium/lift/TestContextTest.java | 162 --------------- .../lift/WebDriverTestContextTest.java | 186 ------------------ .../selenium/lift/find/XPathFinderTest.java | 41 ---- .../lift/match/DisplayedMatcherTest.java | 48 ----- 37 files changed, 2 insertions(+), 2028 deletions(-) delete mode 100644 java/src/org/openqa/selenium/lift/BUILD.bazel delete mode 100644 java/src/org/openqa/selenium/lift/Finders.java delete mode 100644 java/src/org/openqa/selenium/lift/HamcrestWebDriverTestCase.java delete mode 100644 java/src/org/openqa/selenium/lift/Matchers.java delete mode 100644 java/src/org/openqa/selenium/lift/TestContext.java delete mode 100644 java/src/org/openqa/selenium/lift/WebDriverTestContext.java delete mode 100644 java/src/org/openqa/selenium/lift/find/BaseFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/DivFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/Finder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/HtmlTagFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/ImageFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/InputFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/LinkFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/PageTitleFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/TableCellFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/TableFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/find/XPathFinder.java delete mode 100644 java/src/org/openqa/selenium/lift/match/AttributeMatcher.java delete mode 100644 java/src/org/openqa/selenium/lift/match/DisplayedMatcher.java delete mode 100644 java/src/org/openqa/selenium/lift/match/NumericalMatchers.java delete mode 100644 java/src/org/openqa/selenium/lift/match/SelectionMatcher.java delete mode 100644 java/src/org/openqa/selenium/lift/match/TextMatcher.java delete mode 100644 java/src/org/openqa/selenium/lift/match/ValueMatcher.java delete mode 100644 java/test/org/openqa/selenium/lift/BUILD.bazel delete mode 100644 java/test/org/openqa/selenium/lift/HamcrestWebdriverTestCaseTest.java delete mode 100644 java/test/org/openqa/selenium/lift/TestContextTest.java delete mode 100644 java/test/org/openqa/selenium/lift/WebDriverTestContextTest.java delete mode 100644 java/test/org/openqa/selenium/lift/find/XPathFinderTest.java delete mode 100644 java/test/org/openqa/selenium/lift/match/DisplayedMatcherTest.java diff --git a/Rakefile b/Rakefile index 19e5dd1806594..1c4bdda3e9962 100644 --- a/Rakefile +++ b/Rakefile @@ -111,7 +111,6 @@ JAVA_RELEASE_TARGETS = %w[ //java/src/org/openqa/selenium/grid:grid.publish //java/src/org/openqa/selenium/ie:ie.publish //java/src/org/openqa/selenium/json:json.publish - //java/src/org/openqa/selenium/lift:lift.publish //java/src/org/openqa/selenium/manager:manager.publish //java/src/org/openqa/selenium/os:os.publish //java/src/org/openqa/selenium/remote/http:http.publish @@ -153,7 +152,6 @@ task remote_server: ['//java/src/org/openqa/selenium/remote/server'] task safari: ['//java/src/org/openqa/selenium/safari'] task selenium: ['//java/src/org/openqa/selenium:core'] task support: [ - '//java/src/org/openqa/selenium/lift', '//java/src/org/openqa/selenium/support' ] @@ -202,7 +200,6 @@ task test_remote: [ ] task test_safari: ['//java/test/org/openqa/selenium/safari:safari:run'] task test_support: [ - '//java/test/org/openqa/selenium/lift:lift:run', '//java/test/org/openqa/selenium/support:small-tests:run', '//java/test/org/openqa/selenium/support:large-tests:run' ] diff --git a/java/maven_deps.bzl b/java/maven_deps.bzl index 447a4b47c744d..4b3ad2f04d343 100644 --- a/java/maven_deps.bzl +++ b/java/maven_deps.bzl @@ -29,16 +29,6 @@ def selenium_java_deps(): "com.graphql-java:graphql-java:20.2", "com.graphql-java:java-dataloader:3.2.0", "dev.failsafe:failsafe:3.3.2", - maven.artifact( - group = "junit", - artifact = "junit", - version = "4.13.2", - exclusions = [ - "org.hamcrest:hamcrest-all", - "org.hamcrest:hamcrest-core", - "org.hamcrest:hamcrest-library", - ], - ), "io.grpc:grpc-context:1.57.1", "io.lettuce:lettuce-core:6.2.5.RELEASE", "io.netty:netty-buffer:%s" % netty_version, @@ -77,7 +67,6 @@ def selenium_java_deps(): "org.assertj:assertj-core:3.24.2", "org.bouncycastle:bcpkix-jdk15on:1.70", "org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5", - "org.hamcrest:hamcrest:2.2", "org.hsqldb:hsqldb:2.7.2", "org.junit.jupiter:junit-jupiter-api:%s" % junit_jupiter_version, "org.junit.jupiter:junit-jupiter-engine:%s" % junit_jupiter_version, diff --git a/java/maven_install.json b/java/maven_install.json index 8ba656db743fb..abb5c8d6d15eb 100644 --- a/java/maven_install.json +++ b/java/maven_install.json @@ -1,7 +1,7 @@ { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", - "__INPUT_ARTIFACTS_HASH": -486878249, - "__RESOLVED_ARTIFACTS_HASH": 1235473565, + "__INPUT_ARTIFACTS_HASH": -954450372, + "__RESOLVED_ARTIFACTS_HASH": 1161694440, "artifacts": { "com.beust:jcommander": { "shasums": { @@ -496,13 +496,6 @@ }, "version": "1.2.0" }, - "junit:junit": { - "shasums": { - "jar": "8e495b634469d64fb8acfa3495a065cbacc8a0fff55ce1e31007be4c16dc57d3", - "sources": "34181df6482d40ea4c046b063cb53c7ffae94bdf1b1d62695bdf3adf9dea7e3a" - }, - "version": "4.13.2" - }, "net.bytebuddy:byte-buddy": { "shasums": { "jar": "e99761a526df0fefbbd3fe14436b0f953000cdfa5151dc63c0b18d37d9c46f1c", @@ -657,13 +650,6 @@ }, "version": "2.1.5" }, - "org.hamcrest:hamcrest": { - "shasums": { - "jar": "5e62846a89f05cd78cd9c1a553f340d002458380c320455dd1f8fc5497a8a1c1", - "sources": "f49e697dbc70591f91a90dd7f741f5780f53f63f34a416d6a9879499d4d666af" - }, - "version": "2.2" - }, "org.hsqldb:hsqldb": { "shasums": { "jar": "aa455133e664f6a7e6f30cd0cd4f8ad83dfbd94eb717c438548e446784614a92", @@ -1943,40 +1929,6 @@ "org.jaxen.util", "org.jaxen.xom" ], - "junit:junit": [ - "junit.extensions", - "junit.framework", - "junit.runner", - "junit.textui", - "org.junit", - "org.junit.experimental", - "org.junit.experimental.categories", - "org.junit.experimental.max", - "org.junit.experimental.results", - "org.junit.experimental.runners", - "org.junit.experimental.theories", - "org.junit.experimental.theories.internal", - "org.junit.experimental.theories.suppliers", - "org.junit.function", - "org.junit.internal", - "org.junit.internal.builders", - "org.junit.internal.management", - "org.junit.internal.matchers", - "org.junit.internal.requests", - "org.junit.internal.runners", - "org.junit.internal.runners.model", - "org.junit.internal.runners.rules", - "org.junit.internal.runners.statements", - "org.junit.matchers", - "org.junit.rules", - "org.junit.runner", - "org.junit.runner.manipulation", - "org.junit.runner.notification", - "org.junit.runners", - "org.junit.runners.model", - "org.junit.runners.parameterized", - "org.junit.validator" - ], "net.bytebuddy:byte-buddy": [ "net.bytebuddy", "net.bytebuddy.agent.builder", @@ -2607,19 +2559,6 @@ "org.eclipse.egit.github.core.service", "org.eclipse.egit.github.core.util" ], - "org.hamcrest:hamcrest": [ - "org.hamcrest", - "org.hamcrest.beans", - "org.hamcrest.collection", - "org.hamcrest.comparator", - "org.hamcrest.core", - "org.hamcrest.internal", - "org.hamcrest.io", - "org.hamcrest.number", - "org.hamcrest.object", - "org.hamcrest.text", - "org.hamcrest.xml" - ], "org.hsqldb:hsqldb": [ "org.hsqldb", "org.hsqldb.auth", @@ -3188,8 +3127,6 @@ "javax.cache:cache-api:jar:sources", "jaxen:jaxen", "jaxen:jaxen:jar:sources", - "junit:junit", - "junit:junit:jar:sources", "net.bytebuddy:byte-buddy", "net.bytebuddy:byte-buddy-agent", "net.bytebuddy:byte-buddy-agent:jar:sources", @@ -3234,8 +3171,6 @@ "org.dom4j:dom4j:jar:sources", "org.eclipse.mylyn.github:org.eclipse.egit.github.core", "org.eclipse.mylyn.github:org.eclipse.egit.github.core:jar:sources", - "org.hamcrest:hamcrest", - "org.hamcrest:hamcrest:jar:sources", "org.hsqldb:hsqldb", "org.hsqldb:hsqldb:jar:sources", "org.jboss.marshalling:jboss-marshalling", @@ -3441,8 +3376,6 @@ "javax.cache:cache-api:jar:sources", "jaxen:jaxen", "jaxen:jaxen:jar:sources", - "junit:junit", - "junit:junit:jar:sources", "net.bytebuddy:byte-buddy", "net.bytebuddy:byte-buddy-agent", "net.bytebuddy:byte-buddy-agent:jar:sources", @@ -3487,8 +3420,6 @@ "org.dom4j:dom4j:jar:sources", "org.eclipse.mylyn.github:org.eclipse.egit.github.core", "org.eclipse.mylyn.github:org.eclipse.egit.github.core:jar:sources", - "org.hamcrest:hamcrest", - "org.hamcrest:hamcrest:jar:sources", "org.hsqldb:hsqldb", "org.hsqldb:hsqldb:jar:sources", "org.jboss.marshalling:jboss-marshalling", diff --git a/java/src/org/openqa/selenium/grid/BUILD.bazel b/java/src/org/openqa/selenium/grid/BUILD.bazel index e61f15f4f3399..44f40717305bd 100644 --- a/java/src/org/openqa/selenium/grid/BUILD.bazel +++ b/java/src/org/openqa/selenium/grid/BUILD.bazel @@ -108,7 +108,6 @@ maven_bom( "//java/src/org/openqa/selenium/grid:grid", "//java/src/org/openqa/selenium/ie:ie", "//java/src/org/openqa/selenium/json:json", - "//java/src/org/openqa/selenium/lift:lift", "//java/src/org/openqa/selenium/manager:manager", "//java/src/org/openqa/selenium/remote/http:http", "//java/src/org/openqa/selenium/remote:remote", diff --git a/java/src/org/openqa/selenium/lift/BUILD.bazel b/java/src/org/openqa/selenium/lift/BUILD.bazel deleted file mode 100644 index 178d85d8a63ca..0000000000000 --- a/java/src/org/openqa/selenium/lift/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("@rules_jvm_external//:defs.bzl", "artifact") -load("//java:defs.bzl", "java_export") -load("//java:version.bzl", "SE_VERSION") - -java_export( - name = "lift", - srcs = glob(["**/*.java"]), - maven_coordinates = "org.seleniumhq.selenium:lift:%s" % SE_VERSION, - pom_template = "//java/src/org/openqa/selenium:template-pom", - visibility = [ - "//visibility:public", - ], - deps = [ - "//java/src/org/openqa/selenium:core", - "//java/src/org/openqa/selenium/support", - artifact("org.hamcrest:hamcrest"), - artifact("junit:junit"), - ], -) diff --git a/java/src/org/openqa/selenium/lift/Finders.java b/java/src/org/openqa/selenium/lift/Finders.java deleted file mode 100644 index 5b9faa11ceaf4..0000000000000 --- a/java/src/org/openqa/selenium/lift/Finders.java +++ /dev/null @@ -1,149 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Generated source. -package org.openqa.selenium.lift; - -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import org.hamcrest.Description; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.lift.find.BaseFinder; -import org.openqa.selenium.lift.find.Finder; - -@Deprecated -public class Finders { - - public static org.openqa.selenium.lift.find.HtmlTagFinder div() { - return org.openqa.selenium.lift.find.DivFinder.div(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder div(String id) { - return org.openqa.selenium.lift.find.DivFinder.div(id); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder link() { - return org.openqa.selenium.lift.find.LinkFinder.link(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder link(java.lang.String anchorText) { - return org.openqa.selenium.lift.find.LinkFinder.link(anchorText); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder links() { - return org.openqa.selenium.lift.find.LinkFinder.links(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder titles() { - return org.openqa.selenium.lift.find.PageTitleFinder.titles(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder title() { - return org.openqa.selenium.lift.find.PageTitleFinder.title(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder title(String title) { - return org.openqa.selenium.lift.find.PageTitleFinder.title(title); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder images() { - return org.openqa.selenium.lift.find.ImageFinder.images(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder image() { - return org.openqa.selenium.lift.find.ImageFinder.image(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder table() { - return org.openqa.selenium.lift.find.TableFinder.table(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder tables() { - return org.openqa.selenium.lift.find.TableFinder.tables(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder cell() { - return org.openqa.selenium.lift.find.TableCellFinder.cell(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder cells() { - return org.openqa.selenium.lift.find.TableCellFinder.cells(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder imageButton() { - return org.openqa.selenium.lift.find.InputFinder.imageButton(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder imageButton(String label) { - return org.openqa.selenium.lift.find.InputFinder.imageButton(label); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder radioButton() { - return org.openqa.selenium.lift.find.InputFinder.radioButton(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder radioButton(String id) { - return org.openqa.selenium.lift.find.InputFinder.radioButton(id); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder textbox() { - return org.openqa.selenium.lift.find.InputFinder.textbox(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder button() { - return org.openqa.selenium.lift.find.InputFinder.submitButton(); - } - - public static org.openqa.selenium.lift.find.HtmlTagFinder button(String label) { - return org.openqa.selenium.lift.find.InputFinder.submitButton(label); - } - - /** - * A finder which returns the first element matched - such as if you have multiple elements which - * match the finder (such as multiple links with the same text on a page etc) - * - * @param finder finder from which context to search - * @return finder that will return the first match - */ - public static Finder first(final Finder finder) { - return new BaseFinder() { - - @Override - public Collection findFrom(WebDriver context) { - Collection collection = super.findFrom(context); - if (!collection.isEmpty()) { - Iterator iter = collection.iterator(); - return Collections.singletonList(iter.next()); - } - return collection; - } - - @Override - protected Collection extractFrom(WebDriver context) { - return finder.findFrom(context); - } - - @Override - protected void describeTargetTo(Description description) { - description.appendText("first "); - finder.describeTo(description); - } - }; - } -} diff --git a/java/src/org/openqa/selenium/lift/HamcrestWebDriverTestCase.java b/java/src/org/openqa/selenium/lift/HamcrestWebDriverTestCase.java deleted file mode 100644 index 2ce7e0a8e6950..0000000000000 --- a/java/src/org/openqa/selenium/lift/HamcrestWebDriverTestCase.java +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift; - -import static org.openqa.selenium.lift.match.NumericalMatchers.exactly; -import static org.openqa.selenium.lift.match.SelectionMatcher.selection; - -import junit.framework.TestCase; -import org.hamcrest.Matcher; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.lift.find.Finder; - -/** Base class for tests using the LiFT style API to driver WebDriver. */ -@Deprecated -public abstract class HamcrestWebDriverTestCase extends TestCase { - - private static final long DEFAULT_TIMEOUT = 5000; - - private WebDriver driver; - private TestContext context; - - protected abstract WebDriver createDriver(); - - @Override - protected void setUp() throws Exception { - super.setUp(); - driver = createDriver(); - context = new WebDriverTestContext(driver); - } - - @Override - protected void tearDown() throws Exception { - context.quit(); - super.tearDown(); - } - - protected WebDriver getWebDriver() { - return driver; - } - - protected void clickOn(Finder finder) { - context.clickOn(finder); - } - - protected void assertPresenceOf(Finder finder) { - context.assertPresenceOf(finder); - } - - protected void assertPresenceOf( - Matcher cardinalityConstraint, Finder finder) { - context.assertPresenceOf(cardinalityConstraint, finder); - } - - protected void waitFor(Finder finder) { - waitFor(finder, DEFAULT_TIMEOUT); - } - - protected void waitFor(Finder finder, long timeout) { - context.waitFor(finder, timeout); - } - - /** - * Cause the browser to navigate to the given URL - * - * @param url URL - */ - protected void goTo(String url) { - context.goTo(url); - } - - /** - * Type characters into an element of the page, typically an input field - * - * @param text - characters to type - * @param inputFinder - specification for the page element - */ - protected void type(String text, Finder inputFinder) { - context.type(text, inputFinder); - } - - /** - * Syntactic sugar to use with {@link org.openqa.selenium.lift.HamcrestWebDriverTestCase}, e.g. - * type("cheese", into(textbox())); The into() method simply returns its argument. - * - * @param input finder input - * @return the finder - */ - protected Finder into(Finder input) { - return input; - } - - /** - * replace the default {@link TestContext} - * - * @param context context to set - */ - void setContext(TestContext context) { - this.context = context; - } - - /** - * @return the current page source - */ - public String getPageSource() { - return getWebDriver().getPageSource(); - } - - /** - * @return the current page title - */ - public String getTitle() { - return getWebDriver().getTitle(); - } - - /** - * @return the current URL - */ - public String getCurrentUrl() { - return getWebDriver().getCurrentUrl(); - } - - protected void assertSelected(Finder finder) { - assertPresenceOf(finder.with(selection())); - } - - protected void assertNotSelected(Finder finder) { - assertPresenceOf(exactly(0), finder.with(selection())); - } -} diff --git a/java/src/org/openqa/selenium/lift/Matchers.java b/java/src/org/openqa/selenium/lift/Matchers.java deleted file mode 100644 index 40e933fee342c..0000000000000 --- a/java/src/org/openqa/selenium/lift/Matchers.java +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Generated source. -package org.openqa.selenium.lift; - -@Deprecated -public class Matchers { - - public static org.hamcrest.Matcher attribute( - java.lang.String attributeName, org.hamcrest.Matcher valueMatcher) { - return org.openqa.selenium.lift.match.AttributeMatcher.attribute(attributeName, valueMatcher); - } - - public static org.hamcrest.Matcher atLeast(int count) { - return org.openqa.selenium.lift.match.NumericalMatchers.atLeast(count); - } - - public static org.hamcrest.Matcher exactly(int count) { - return org.openqa.selenium.lift.match.NumericalMatchers.exactly(count); - } - - public static org.hamcrest.Matcher text( - org.hamcrest.Matcher textMatcher) { - return org.openqa.selenium.lift.match.TextMatcher.text(textMatcher); - } - - public static org.hamcrest.Matcher selection() { - return org.openqa.selenium.lift.match.SelectionMatcher.selection(); - } - - public static org.hamcrest.Matcher value(Object value) { - return org.openqa.selenium.lift.match.ValueMatcher.value(value); - } - - public static org.hamcrest.Matcher displayed() { - return org.openqa.selenium.lift.match.DisplayedMatcher.displayed(); - } -} diff --git a/java/src/org/openqa/selenium/lift/TestContext.java b/java/src/org/openqa/selenium/lift/TestContext.java deleted file mode 100644 index 7ce36a1105c0a..0000000000000 --- a/java/src/org/openqa/selenium/lift/TestContext.java +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift; - -import org.hamcrest.Matcher; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.lift.find.Finder; - -/** Interface for objects that provide a context (maintaining any state) for web tests. */ -@Deprecated -public interface TestContext { - - void goTo(String url); - - void assertPresenceOf(Finder finder); - - void assertPresenceOf( - Matcher cardinalityConstraint, Finder finder); - - void type(String input, Finder finder); - - void clickOn(Finder finder); - - void waitFor(Finder finder, long timeout); - - void quit(); -} diff --git a/java/src/org/openqa/selenium/lift/WebDriverTestContext.java b/java/src/org/openqa/selenium/lift/WebDriverTestContext.java deleted file mode 100644 index effdeb6e04fbd..0000000000000 --- a/java/src/org/openqa/selenium/lift/WebDriverTestContext.java +++ /dev/null @@ -1,154 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift; - -import static org.openqa.selenium.lift.match.NumericalMatchers.atLeast; - -import java.time.Clock; -import java.time.Duration; -import java.util.Collection; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.StringDescription; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.lift.find.Finder; -import org.openqa.selenium.support.ui.ExpectedCondition; -import org.openqa.selenium.support.ui.Sleeper; -import org.openqa.selenium.support.ui.Wait; -import org.openqa.selenium.support.ui.WebDriverWait; - -/** Gives the context for a test, holds page state, and interacts with the {@link WebDriver}. */ -@Deprecated -public class WebDriverTestContext implements TestContext { - - private WebDriver driver; - private final Clock clock; - private final Sleeper sleeper; - - public WebDriverTestContext(WebDriver driver) { - this(driver, Clock.systemDefaultZone(), Sleeper.SYSTEM_SLEEPER); - } - - WebDriverTestContext(WebDriver driver, Clock clock, Sleeper sleeper) { - this.driver = driver; - this.clock = clock; - this.sleeper = sleeper; - } - - @Override - public void quit() { - driver.quit(); - } - - @Override - public void goTo(String url) { - driver.get(url); - } - - @Override - public void assertPresenceOf(Finder finder) { - assertPresenceOf(atLeast(1), finder); - } - - @Override - public void assertPresenceOf( - Matcher cardinalityConstraint, Finder finder) { - Collection foundElements = finder.findFrom(driver); - if (!cardinalityConstraint.matches(foundElements.size())) { - Description description = new StringDescription(); - description - .appendText("\nExpected: ") - .appendDescriptionOf(cardinalityConstraint) - .appendText(" ") - .appendDescriptionOf(finder) - .appendText("\n got: ") - .appendValue(foundElements.size()) - .appendText(" ") - .appendDescriptionOf(finder) - .appendText("\n"); - - failWith(description.toString()); - } - } - - @Override - public void type(String input, Finder finder) { - WebElement element = findOneElementTo("type into", finder); - element.sendKeys(input); - } - - @Override - public void clickOn(Finder finder) { - WebElement element = findOneElementTo("click on", finder); - element.click(); - } - - public void clickOnFirst(Finder finder) { - WebElement element = findFirstElementTo("click on", finder); - element.click(); - } - - private WebElement findFirstElementTo(String action, Finder finder) { - Collection foundElements = finder.findFrom(driver); - if (foundElements.isEmpty()) { - failWith("could not find element to " + action); - } - - return foundElements.iterator().next(); - } - - private WebElement findOneElementTo(String action, Finder finder) { - Collection foundElements = finder.findFrom(driver); - if (foundElements.isEmpty()) { - failWith("could not find element to " + action); - } else if (foundElements.size() > 1) { - failWith("did not know what to " + action + " - ambiguous"); - } - - return foundElements.iterator().next(); - } - - private void failWith(String message) throws AssertionError { - throw new java.lang.AssertionError(message); - } - - @Override - public void waitFor(final Finder finder, final long timeoutMillis) { - final ExpectedCondition elementsDisplayedPredicate = - driver -> finder.findFrom(driver).stream().anyMatch(WebElement::isDisplayed); - - final long defaultSleepTimeoutMillis = 500; - final long sleepTimeout = - (timeoutMillis > defaultSleepTimeoutMillis) ? defaultSleepTimeoutMillis : timeoutMillis / 2; - - Wait wait = - new WebDriverWait( - driver, - Duration.ofMillis(timeoutMillis), - Duration.ofMillis(sleepTimeout), - clock, - sleeper) { - @Override - protected RuntimeException timeoutException(String message, Throwable lastException) { - throw new AssertionError("Element was not rendered within " + timeoutMillis + "ms"); - } - }; - wait.until(elementsDisplayedPredicate); - } -} diff --git a/java/src/org/openqa/selenium/lift/find/BaseFinder.java b/java/src/org/openqa/selenium/lift/find/BaseFinder.java deleted file mode 100644 index 99fd2588302a6..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/BaseFinder.java +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; - -/** - * Base class for {@link Finder}s. These allow the creation of a specification to be applied to - * objects of type T, to identify and return a Collection of any contained objects of type S. - */ -@Deprecated -public abstract class BaseFinder implements Finder { - - protected final List> matchers = new ArrayList<>(); - - @Override - public Collection findFrom(T context) { - - Collection found = extractFrom(context); - - if (matchers.isEmpty()) { - return found; - } - return allMatching(matchers, found); - } - - @Override - public Finder with(Matcher matcher) { - this.matchers.add(matcher); - return this; - } - - @Override - public void describeTo(Description description) { - describeTargetTo(description); - for (Matcher matcher : matchers) { - if (matcher != null) { - description.appendText(" with "); - matcher.describeTo(description); - } - } - } - - protected abstract Collection extractFrom(T context); - - protected abstract void describeTargetTo(Description description); - - protected Collection allMatching(List> matchers, Collection items) { - Collection temp = new ArrayList<>(); - for (S item : items) { - if (allOf(matchers).matches(item)) { - temp.add(item); - } - } - return temp; - } - - private Matcher allOf(final List> matcherList) { - return new TypeSafeMatcher() { - @Override - public boolean matchesSafely(S item) { - for (Matcher matcher : matcherList) { - if (!matcher.matches(item)) { - return false; - } - } - return true; - } - - @Override - public void describeTo(Description description) { - for (Matcher matcher : matcherList) { - matcher.describeTo(description); - } - } - }; - } -} diff --git a/java/src/org/openqa/selenium/lift/find/DivFinder.java b/java/src/org/openqa/selenium/lift/find/DivFinder.java deleted file mode 100644 index e89f0427540da..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/DivFinder.java +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -import static org.hamcrest.Matchers.equalTo; -import static org.openqa.selenium.lift.match.AttributeMatcher.attribute; - -/** {@link Finder} for HTML div tags. */ -@Deprecated -public class DivFinder extends HtmlTagFinder { - - @Override - protected String tagDescription() { - return "div"; - } - - @Override - protected String tagName() { - return "div"; - } - - public static HtmlTagFinder div() { - return new DivFinder(); - } - - public static HtmlTagFinder div(String id) { - return div().with(attribute("id", equalTo(id))); - } -} diff --git a/java/src/org/openqa/selenium/lift/find/Finder.java b/java/src/org/openqa/selenium/lift/find/Finder.java deleted file mode 100644 index b7a7ddea273c4..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/Finder.java +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -import java.util.Collection; -import org.hamcrest.Matcher; -import org.hamcrest.SelfDescribing; - -@Deprecated -public interface Finder extends SelfDescribing { - Collection findFrom(T context); - - Finder with(Matcher textMatcher); -} diff --git a/java/src/org/openqa/selenium/lift/find/HtmlTagFinder.java b/java/src/org/openqa/selenium/lift/find/HtmlTagFinder.java deleted file mode 100644 index bf198a7d3fa02..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/HtmlTagFinder.java +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -import java.util.Collection; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - -/** - * Base {@link Finder} for all types of HTML tags. Subclasses should be created for each specific - * tag, specifying the tag name (e.g. "a" in the case or an anchor tag), and a description. - */ -@Deprecated -public abstract class HtmlTagFinder extends BaseFinder { - - @Override - protected Collection extractFrom(WebDriver context) { - return context.findElements(By.xpath("//" + tagName())); - } - - @Override - protected void describeTargetTo(Description description) { - description.appendText(tagDescription()); - } - - @Override // more specific return type - public HtmlTagFinder with(Matcher matcher) { - super.with(matcher); - return this; - } - - protected abstract String tagName(); - - protected abstract String tagDescription(); -} diff --git a/java/src/org/openqa/selenium/lift/find/ImageFinder.java b/java/src/org/openqa/selenium/lift/find/ImageFinder.java deleted file mode 100644 index 0dcdd03fc0f29..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/ImageFinder.java +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -/** {@link Finder} for HTML image tags. */ -@Deprecated -public class ImageFinder extends HtmlTagFinder { - - @Override - protected String tagDescription() { - return "image"; - } - - @Override - protected String tagName() { - return "img"; - } - - public static HtmlTagFinder image() { - return new ImageFinder(); - } - - public static HtmlTagFinder images() { - return new ImageFinder(); - } -} diff --git a/java/src/org/openqa/selenium/lift/find/InputFinder.java b/java/src/org/openqa/selenium/lift/find/InputFinder.java deleted file mode 100644 index a12228076a332..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/InputFinder.java +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -import static org.hamcrest.Matchers.equalTo; -import static org.openqa.selenium.lift.Matchers.attribute; -import static org.openqa.selenium.lift.Matchers.value; - -/** {@link Finder} for HTML input tags. */ -@Deprecated -public class InputFinder extends HtmlTagFinder { - - @Override - protected String tagDescription() { - return "input field"; - } - - @Override - protected String tagName() { - return "input"; - } - - public static HtmlTagFinder textbox() { - return new InputFinder().with(attribute("type", equalTo("text"))); - } - - public static HtmlTagFinder imageButton() { - return new InputFinder().with(attribute("type", equalTo("image"))); - } - - public static HtmlTagFinder imageButton(String label) { - return imageButton().with(value((label))); - } - - public static HtmlTagFinder radioButton() { - return new InputFinder().with(attribute("type", equalTo("radio"))); - } - - public static HtmlTagFinder radioButton(String id) { - return radioButton().with(attribute("id", equalTo(id))); - } - - public static HtmlTagFinder submitButton() { - return new InputFinder().with(attribute("type", equalTo("submit"))); - } - - public static HtmlTagFinder submitButton(String label) { - return submitButton().with(value(label)); - } -} diff --git a/java/src/org/openqa/selenium/lift/find/LinkFinder.java b/java/src/org/openqa/selenium/lift/find/LinkFinder.java deleted file mode 100644 index b42e0b31e5fef..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/LinkFinder.java +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -import static org.hamcrest.Matchers.equalTo; -import static org.openqa.selenium.lift.match.TextMatcher.text; - -/** A {@link Finder} for HTML anchor tags, "links". */ -@Deprecated -public class LinkFinder extends HtmlTagFinder { - - private LinkFinder() {} - - @Override - protected String tagName() { - return "a"; - } - - @Override - protected String tagDescription() { - return "link"; - } - - public static HtmlTagFinder link() { - return new LinkFinder(); - } - - public static HtmlTagFinder link(String linkText) { - return new LinkFinder().with(text(equalTo(linkText))); - } - - public static HtmlTagFinder links() { - return link(); - } -} diff --git a/java/src/org/openqa/selenium/lift/find/PageTitleFinder.java b/java/src/org/openqa/selenium/lift/find/PageTitleFinder.java deleted file mode 100644 index 2142708df8180..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/PageTitleFinder.java +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -import static org.hamcrest.Matchers.equalTo; -import static org.openqa.selenium.lift.match.TextMatcher.text; - -/** A {@link Finder} for HTML title tags. */ -@Deprecated -public class PageTitleFinder extends HtmlTagFinder { - - private PageTitleFinder() {} - - @Override - protected String tagName() { - return "title"; - } - - @Override - protected String tagDescription() { - return "page title"; - } - - public static HtmlTagFinder title() { - return new PageTitleFinder(); - } - - public static HtmlTagFinder title(String title) { - return new PageTitleFinder().with(text(equalTo(title))); - } - - public static HtmlTagFinder titles() { - return new PageTitleFinder(); - } -} diff --git a/java/src/org/openqa/selenium/lift/find/TableCellFinder.java b/java/src/org/openqa/selenium/lift/find/TableCellFinder.java deleted file mode 100644 index ec098b59c669e..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/TableCellFinder.java +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -/** A {@link Finder} for HTML table cell "td" tags. */ -@Deprecated -public class TableCellFinder extends HtmlTagFinder { - - private TableCellFinder() {} - - @Override - protected String tagName() { - return "td"; - } - - @Override - protected String tagDescription() { - return "table cell"; - } - - public static HtmlTagFinder cell() { - return new TableCellFinder(); - } - - public static HtmlTagFinder cells() { - return cell(); - } -} diff --git a/java/src/org/openqa/selenium/lift/find/TableFinder.java b/java/src/org/openqa/selenium/lift/find/TableFinder.java deleted file mode 100644 index 3c9d4460639b5..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/TableFinder.java +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -/** A {@link Finder} for HTML table tags. */ -@Deprecated -public class TableFinder extends HtmlTagFinder { - - private TableFinder() {} - - @Override - protected String tagName() { - return "table"; - } - - @Override - protected String tagDescription() { - return "table"; - } - - public static HtmlTagFinder table() { - return new TableFinder(); - } - - public static HtmlTagFinder tables() { - return table(); - } -} diff --git a/java/src/org/openqa/selenium/lift/find/XPathFinder.java b/java/src/org/openqa/selenium/lift/find/XPathFinder.java deleted file mode 100644 index e888e0a7b3e31..0000000000000 --- a/java/src/org/openqa/selenium/lift/find/XPathFinder.java +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package org.openqa.selenium.lift.find; - -import java.util.Collection; -import org.hamcrest.Description; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - -/** A {@link Finder} for elements using XPath expressions */ -@Deprecated -public class XPathFinder extends BaseFinder { - private final String xpath; - - public XPathFinder(String xpath) { - this.xpath = xpath; - } - - @Override - protected Collection extractFrom(WebDriver context) { - return context.findElements(By.xpath(xpath)); - } - - @Override - protected void describeTargetTo(Description description) { - description.appendText("XPath "); - description.appendText(xpath); - } -} diff --git a/java/src/org/openqa/selenium/lift/match/AttributeMatcher.java b/java/src/org/openqa/selenium/lift/match/AttributeMatcher.java deleted file mode 100644 index 89150f059a979..0000000000000 --- a/java/src/org/openqa/selenium/lift/match/AttributeMatcher.java +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.match; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.openqa.selenium.WebElement; - -/** hamcrest matcher for attributes of {@link WebElement}s. */ -@Deprecated -public class AttributeMatcher extends TypeSafeMatcher { - - private final Matcher matcher; - private final String name; - - AttributeMatcher(String name, Matcher matcher) { - this.name = name; - this.matcher = matcher; - } - - @Override - public boolean matchesSafely(WebElement item) { - return matcher.matches(item.getAttribute(name)); - } - - @Override - public void describeTo(Description description) { - description.appendText("attribute ").appendValue(name); - matcher.describeTo(description); - } - - public static Matcher attribute( - final String name, final Matcher valueMatcher) { - return new AttributeMatcher(name, valueMatcher); - } -} diff --git a/java/src/org/openqa/selenium/lift/match/DisplayedMatcher.java b/java/src/org/openqa/selenium/lift/match/DisplayedMatcher.java deleted file mode 100644 index 1b04e0e05adcc..0000000000000 --- a/java/src/org/openqa/selenium/lift/match/DisplayedMatcher.java +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package org.openqa.selenium.lift.match; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.openqa.selenium.WebElement; - -/** Hamcrest matcher for displayed status of {@link WebElement}s. */ -@Deprecated -public class DisplayedMatcher extends TypeSafeMatcher { - - private DisplayedMatcher() {} - - @Override - public void describeTo(Description description) { - description.appendText("displayed"); - } - - @Override - public boolean matchesSafely(WebElement item) { - return item.isDisplayed(); - } - - public static Matcher displayed() { - return new DisplayedMatcher(); - } -} diff --git a/java/src/org/openqa/selenium/lift/match/NumericalMatchers.java b/java/src/org/openqa/selenium/lift/match/NumericalMatchers.java deleted file mode 100644 index c92b178fc4c97..0000000000000 --- a/java/src/org/openqa/selenium/lift/match/NumericalMatchers.java +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.match; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; - -import org.hamcrest.Matcher; - -/** Various numerical hamcrest {@link Matcher}s. */ -@Deprecated -public class NumericalMatchers { - - public static Matcher atLeast(int i) { - return greaterThan(i - 1); - } - - public static Matcher exactly(int i) { - return equalTo(i); - } -} diff --git a/java/src/org/openqa/selenium/lift/match/SelectionMatcher.java b/java/src/org/openqa/selenium/lift/match/SelectionMatcher.java deleted file mode 100644 index aa84966fcea1a..0000000000000 --- a/java/src/org/openqa/selenium/lift/match/SelectionMatcher.java +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.match; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.openqa.selenium.WebElement; - -/** Matcher to match a selected element (e.g. a radio button). */ -@Deprecated -public class SelectionMatcher extends TypeSafeMatcher { - - @Override - public boolean matchesSafely(WebElement item) { - return item.isSelected(); - } - - @Override - public void describeTo(Description description) { - description.appendText("should be selected"); - } - - public static Matcher selection() { - return new SelectionMatcher(); - } -} diff --git a/java/src/org/openqa/selenium/lift/match/TextMatcher.java b/java/src/org/openqa/selenium/lift/match/TextMatcher.java deleted file mode 100644 index ca70cbd06961c..0000000000000 --- a/java/src/org/openqa/selenium/lift/match/TextMatcher.java +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.match; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.openqa.selenium.WebElement; - -/** {@link Matcher} for matching text content within {@link WebElement}s. */ -@Deprecated -public class TextMatcher extends TypeSafeMatcher { - - private final Matcher matcher; - - TextMatcher(Matcher matcher) { - this.matcher = matcher; - } - - @Override - public boolean matchesSafely(WebElement item) { - return matcher.matches(item.getText()); - } - - @Override - public void describeTo(Description description) { - description.appendText("text "); - matcher.describeTo(description); - } - - public static Matcher text(final Matcher textMatcher) { - return new TextMatcher(textMatcher); - } -} diff --git a/java/src/org/openqa/selenium/lift/match/ValueMatcher.java b/java/src/org/openqa/selenium/lift/match/ValueMatcher.java deleted file mode 100644 index f316ff2f42e20..0000000000000 --- a/java/src/org/openqa/selenium/lift/match/ValueMatcher.java +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.match; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.openqa.selenium.WebElement; - -/** Matches the value of an element, for example an input field. */ -@Deprecated -public class ValueMatcher extends TypeSafeMatcher { - - private final Object value; - - public ValueMatcher(Object value) { - this.value = value; - } - - @Override - public boolean matchesSafely(WebElement item) { - return item.getAttribute("value").equals(value); - } - - @Override - public void describeTo(Description description) { - description.appendText("should have value ").appendValue(value); - } - - public static Matcher value(final Object value) { - return new ValueMatcher(value); - } -} diff --git a/java/test/org/openqa/selenium/bidi/BUILD.bazel b/java/test/org/openqa/selenium/bidi/BUILD.bazel index df2d3e30574ea..f9d9f4eed1aa5 100644 --- a/java/test/org/openqa/selenium/bidi/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/BUILD.bazel @@ -25,6 +25,5 @@ java_selenium_test_suite( artifact("com.google.guava:guava"), artifact("org.junit.jupiter:junit-jupiter-api"), artifact("org.assertj:assertj-core"), - artifact("org.hamcrest:hamcrest"), ] + JUNIT5_DEPS, ) diff --git a/java/test/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel b/java/test/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel index df2d3e30574ea..f9d9f4eed1aa5 100644 --- a/java/test/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel @@ -25,6 +25,5 @@ java_selenium_test_suite( artifact("com.google.guava:guava"), artifact("org.junit.jupiter:junit-jupiter-api"), artifact("org.assertj:assertj-core"), - artifact("org.hamcrest:hamcrest"), ] + JUNIT5_DEPS, ) diff --git a/java/test/org/openqa/selenium/bidi/log/BUILD.bazel b/java/test/org/openqa/selenium/bidi/log/BUILD.bazel index df2d3e30574ea..f9d9f4eed1aa5 100644 --- a/java/test/org/openqa/selenium/bidi/log/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/log/BUILD.bazel @@ -25,6 +25,5 @@ java_selenium_test_suite( artifact("com.google.guava:guava"), artifact("org.junit.jupiter:junit-jupiter-api"), artifact("org.assertj:assertj-core"), - artifact("org.hamcrest:hamcrest"), ] + JUNIT5_DEPS, ) diff --git a/java/test/org/openqa/selenium/devtools/BUILD.bazel b/java/test/org/openqa/selenium/devtools/BUILD.bazel index e17756a797b09..c83bfb39a33b9 100644 --- a/java/test/org/openqa/selenium/devtools/BUILD.bazel +++ b/java/test/org/openqa/selenium/devtools/BUILD.bazel @@ -47,6 +47,5 @@ java_library( "//java/test/org/openqa/selenium/testing/drivers", artifact("org.junit.jupiter:junit-jupiter-api"), artifact("org.assertj:assertj-core"), - artifact("org.hamcrest:hamcrest"), ] + JUNIT5_DEPS, ) diff --git a/java/test/org/openqa/selenium/lift/BUILD.bazel b/java/test/org/openqa/selenium/lift/BUILD.bazel deleted file mode 100644 index 7f5c6b8669935..0000000000000 --- a/java/test/org/openqa/selenium/lift/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_jvm_external//:defs.bzl", "artifact") -load("//java:defs.bzl", "JUNIT5_DEPS", "java_test_suite") - -java_test_suite( - name = "lift", - size = "small", - srcs = glob(["**/*Test.java"]), - deps = [ - "//java/src/org/openqa/selenium:core", - "//java/src/org/openqa/selenium/lift", - "//java/test/org/openqa/selenium/support/ui:clock", - artifact("org.junit.jupiter:junit-jupiter-api"), - artifact("org.assertj:assertj-core"), - artifact("org.hamcrest:hamcrest"), - artifact("org.mockito:mockito-core"), - ] + JUNIT5_DEPS, -) diff --git a/java/test/org/openqa/selenium/lift/HamcrestWebdriverTestCaseTest.java b/java/test/org/openqa/selenium/lift/HamcrestWebdriverTestCaseTest.java deleted file mode 100644 index 8828a73becaac..0000000000000 --- a/java/test/org/openqa/selenium/lift/HamcrestWebdriverTestCaseTest.java +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -import org.hamcrest.Matcher; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InOrder; -import org.mockito.Mockito; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.lift.find.Finder; - -/** - * Unit test for {@link HamcrestWebDriverTestCase}. - * - * @author rchatley (Robert Chatley) - */ -@SuppressWarnings("unchecked") -class HamcrestWebdriverTestCaseTest { - - final String text = "abcde"; - final String url = "http://www.example.com"; - Finder something; - Matcher someNumberOf; - - HamcrestWebDriverTestCase testcase; - - @BeforeEach - public void createMocks() { - testcase = createTestCase(); - - something = mock(Finder.class); - someNumberOf = mock(Matcher.class); - } - - @Test - void delegatesAllCallsToItsTestContext() { - - final TestContext testContext = mock(TestContext.class); - testcase.setContext(testContext); - - testcase.goTo(url); - testcase.clickOn(something); - testcase.type(text, something); - testcase.assertPresenceOf(something); - testcase.assertPresenceOf(someNumberOf, something); - - InOrder order = Mockito.inOrder(testContext); - order.verify(testContext).goTo(url); - order.verify(testContext).clickOn(something); - order.verify(testContext).type(text, something); - order.verify(testContext).assertPresenceOf(something); - order.verify(testContext).assertPresenceOf(someNumberOf, something); - order.verifyNoMoreInteractions(); - } - - @Test - void providesSyntacticSugarMethodNamedInto() { - Finder result = testcase.into(something); - assertThat(result).isEqualTo(something); - } - - private HamcrestWebDriverTestCase createTestCase() { - return new HamcrestWebDriverTestCase() { - - @Override - protected WebDriver createDriver() { - return mock(WebDriver.class); - } - }; - } -} diff --git a/java/test/org/openqa/selenium/lift/TestContextTest.java b/java/test/org/openqa/selenium/lift/TestContextTest.java deleted file mode 100644 index 5a895a289dd99..0000000000000 --- a/java/test/org/openqa/selenium/lift/TestContextTest.java +++ /dev/null @@ -1,162 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openqa.selenium.lift.Finders.first; -import static org.openqa.selenium.lift.match.NumericalMatchers.atLeast; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import org.hamcrest.Description; -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.lift.find.Finder; - -/** - * Unit test for {@link WebDriverTestContext}. - * - * @author rchatley (Robert Chatley) - */ -class TestContextTest { - - private WebDriver webdriver; - private TestContext context; - private WebElement element1; - private WebElement element2; - - @BeforeEach - public void createMocks() { - webdriver = mock(WebDriver.class); - context = new WebDriverTestContext(webdriver); - element1 = mock(WebElement.class); - element2 = mock(WebElement.class); - } - - @Test - void isCreatedWithAWebDriverImplementation() { - new WebDriverTestContext(webdriver); - } - - @Test - void canNavigateToAGivenUrl() { - - final String url = "http://www.example.com"; - - context.goTo(url); - verify(webdriver).get(url); - } - - @SuppressWarnings("unchecked") - @Test - void canAssertPresenceOfWebElements() { - - final Finder finder = mock(Finder.class); - - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - - context.assertPresenceOf(finder); - } - - @SuppressWarnings("unchecked") - @Test - void canCheckQuantitiesOfWebElementsAndThrowsExceptionOnMismatch() { - - final Finder finder = mock(Finder.class); - - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - - try { - context.assertPresenceOf(atLeast(2), finder); - fail("should have failed as only one element found"); - } catch (AssertionError error) { - // expected - assertThat(error.getMessage()).contains("a value greater than <1>"); - } - - // From producing the error message. - verify(finder, times(2)).describeTo(any(Description.class)); - } - - @SuppressWarnings("unchecked") - @Test - void canDirectTextInputToSpecificElements() { - final Finder finder = mock(Finder.class); - final String inputText = "test"; - - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - - context.type(inputText, finder); - verify(element1).sendKeys(inputText); - } - - @SuppressWarnings("unchecked") - @Test - void canTriggerClicksOnSpecificElements() { - final Finder finder = mock(Finder.class); - - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - - context.clickOn(finder); - verify(element1).click(); - } - - @SuppressWarnings("unchecked") - @Test - void canTriggerClicksOnFirstElement() { - final Finder finder = mock(Finder.class); - - when(finder.findFrom(webdriver)).thenReturn(twoElements()); - - context.clickOn(first(finder)); - verify(element1).click(); - } - - @SuppressWarnings("unchecked") - @Test - void throwsAnExceptionIfTheFinderReturnsAmbiguousResults() { - final Finder finder = mock(Finder.class); - - when(finder.findFrom(webdriver)).thenReturn(twoElements()); - - try { - context.clickOn(finder); - fail("should have failed as more than one element found"); - } catch (AssertionError error) { - // expected - assertThat(error.getMessage()).contains("did not know what to click on"); - } - } - - private Collection oneElement() { - return Collections.singleton(element1); - } - - private Collection twoElements() { - return Arrays.asList(element1, element2); - } -} diff --git a/java/test/org/openqa/selenium/lift/WebDriverTestContextTest.java b/java/test/org/openqa/selenium/lift/WebDriverTestContextTest.java deleted file mode 100644 index 0654847bfdbab..0000000000000 --- a/java/test/org/openqa/selenium/lift/WebDriverTestContextTest.java +++ /dev/null @@ -1,186 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openqa.selenium.lift.match.NumericalMatchers.atLeast; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import org.hamcrest.Description; -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.lift.find.Finder; -import org.openqa.selenium.support.ui.TickingClock; - -/** - * Unit test for {@link WebDriverTestContext}. - * - * @author rchatley (Robert Chatley) - */ -class WebDriverTestContextTest { - - WebDriver webdriver; - TestContext context; - WebElement element; - WebElement element2; - Finder finder; - TickingClock clock; - private static final int CLOCK_INCREMENT = 300; - final int TIMEOUT = CLOCK_INCREMENT * 3; - - @BeforeEach - public void createMocks() { - webdriver = mock(WebDriver.class); - context = new WebDriverTestContext(webdriver); - element = mock(WebElement.class); - element2 = mock(WebElement.class); - finder = mockFinder(); - clock = new TickingClock(); - } - - @Test - void isCreatedWithAWebDriverImplementation() { - new WebDriverTestContext(webdriver); - } - - @Test - void canNavigateToAGivenUrl() { - final String url = "http://www.example.com"; - - context.goTo(url); - - verify(webdriver).get(url); - } - - @Test - void canAssertPresenceOfWebElements() { - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - - context.assertPresenceOf(finder); - } - - @Test - void canCheckQuantitiesOfWebElementsAndThrowsExceptionOnMismatch() { - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - - try { - context.assertPresenceOf(atLeast(2), finder); - fail("should have failed as only one element found"); - } catch (AssertionError error) { - // expected - assertThat(error.getMessage()).contains("a value greater than <1>"); - } - - // In producing the error message. - verify(finder, times(2)).describeTo(any(Description.class)); - } - - @Test - void canDirectTextInputToSpecificElements() { - final String inputText = "test"; - - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - context.type(inputText, finder); - verify(element).sendKeys(inputText); - } - - @Test - void canTriggerClicksOnSpecificElements() { - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - context.clickOn(finder); - verify(element).click(); - } - - @Test - void throwsAnExceptionIfTheFinderReturnsAmbiguousResults() { - when(finder.findFrom(webdriver)).thenReturn(twoElements()); - - try { - context.clickOn(finder); - fail("should have failed as more than one element found"); - } catch (AssertionError error) { - // expected - assertThat(error.getMessage()).contains("did not know what to click on"); - } - } - - @Test - void supportsWaitingForElementToAppear() { - context = new WebDriverTestContext(webdriver, clock, clock); - - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - when(element.isDisplayed()).thenReturn(true); - - context.waitFor(finder, TIMEOUT); - } - - @Test - void supportsWaitingForElementToAppearWithTimeout() { - context = new WebDriverTestContext(webdriver, clock, clock); - - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - when(element.isDisplayed()).thenReturn(false, true); - - context.waitFor(finder, TIMEOUT); - verify(finder, times(2)).findFrom(webdriver); - verify(element, times(2)).isDisplayed(); - } - - @Test - void failsAssertionIfElementNotDisplayedBeforeTimeout() { - context = new WebDriverTestContext(webdriver, clock, clock); - - when(finder.findFrom(webdriver)).thenReturn(oneElement()); - - try { - context.waitFor(finder, TIMEOUT); - fail("should have failed as element not displayed before timeout"); - } catch (AssertionError error) { - // expected - assertThat(error.getMessage()) - .contains(String.format("Element was not rendered within %dms", TIMEOUT)); - } - - verify(finder, atLeastOnce()).findFrom(webdriver); - verify(element, atLeastOnce()).isDisplayed(); - } - - @SuppressWarnings("unchecked") - Finder mockFinder() { - return mock(Finder.class); - } - - private Collection oneElement() { - return Collections.singleton(element); - } - - private Collection twoElements() { - return Arrays.asList(element, element2); - } -} diff --git a/java/test/org/openqa/selenium/lift/find/XPathFinderTest.java b/java/test/org/openqa/selenium/lift/find/XPathFinderTest.java deleted file mode 100644 index 3744f93931d89..0000000000000 --- a/java/test/org/openqa/selenium/lift/find/XPathFinderTest.java +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.lift.find; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; - -class XPathFinderTest { - - @Test - void shouldReturnManyElements() { - final String xpath = "//body"; - - XPathFinder finder = new XPathFinder(xpath); - - final WebDriver driver = mock(WebDriver.class); - - finder.extractFrom(driver); - - verify(driver).findElements(By.xpath(xpath)); - } -} diff --git a/java/test/org/openqa/selenium/lift/match/DisplayedMatcherTest.java b/java/test/org/openqa/selenium/lift/match/DisplayedMatcherTest.java deleted file mode 100644 index c18372ab3b842..0000000000000 --- a/java/test/org/openqa/selenium/lift/match/DisplayedMatcherTest.java +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package org.openqa.selenium.lift.match; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.openqa.selenium.lift.match.DisplayedMatcher.displayed; - -import org.junit.jupiter.api.Test; -import org.openqa.selenium.WebElement; - -class DisplayedMatcherTest { - - @Test - void testShouldNotFailForDisplayedWebElement() { - WebElement element = createWebElementWithDisplayed(true); - assertThat(element, is(displayed())); - } - - @Test - void testShouldFailForNotDisplayedWebElement() { - final WebElement element = createWebElementWithDisplayed(false); - assertThat(element, is(not(displayed()))); - } - - private WebElement createWebElementWithDisplayed(final boolean displayed) { - final WebElement element = mock(WebElement.class); - when(element.isDisplayed()).thenReturn(displayed); - return element; - } -}