diff --git a/build.gradle b/build.gradle index 7a11c584a..f453956c9 100644 --- a/build.gradle +++ b/build.gradle @@ -55,8 +55,6 @@ dependencies { implementation 'commons-validator:commons-validator:1.7' implementation 'org.apache.commons:commons-lang3:3.12.0' implementation 'commons-io:commons-io:2.11.0' - implementation 'org.springframework:spring-context:5.3.18' - implementation 'org.aspectj:aspectjweaver:1.9.9.1' implementation 'org.slf4j:slf4j-api:1.7.36' testImplementation 'junit:junit:4.13.2' diff --git a/src/main/java/io/appium/java_client/events/DefaultAspect.java b/src/main/java/io/appium/java_client/events/DefaultAspect.java deleted file mode 100644 index bb38d80e6..000000000 --- a/src/main/java/io/appium/java_client/events/DefaultAspect.java +++ /dev/null @@ -1,563 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events; - -import static io.appium.java_client.events.DefaultBeanConfiguration.COMPONENT_BEAN; - -import com.google.common.collect.ImmutableList; - -import io.appium.java_client.events.api.Listener; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.After; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.openqa.selenium.Alert; -import org.openqa.selenium.ContextAware; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.springframework.context.support.AbstractApplicationContext; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -@SuppressWarnings("unused") -@Aspect -class DefaultAspect { - - private static final List> listenable = ImmutableList.of(WebDriver.class, - WebElement.class, WebDriver.Navigation.class, WebDriver.TargetLocator.class, - ContextAware.class, Alert.class, WebDriver.Options.class, WebDriver.Window.class); - - private static final String EXECUTION_NAVIGATION_TO = "execution(* org.openqa.selenium.WebDriver." - + "Navigation.get(..)) || " - + "execution(* org.openqa.selenium.WebDriver.Navigation.to(..)) || " - + "execution(* org.openqa.selenium.WebDriver.get(..))"; - private static final String EXECUTION_NAVIGATION_BACK = "execution(* org.openqa.selenium.WebDriver." - + "Navigation.back(..))"; - private static final String EXECUTION_NAVIGATION_FORWARD = "execution(* org.openqa.selenium.WebDriver." - + "Navigation.forward(..))"; - private static final String EXECUTION_NAVIGATION_REFRESH = "execution(* org.openqa.selenium.WebDriver." - + "Navigation.refresh(..))"; - private static final String EXECUTION_SEARCH = "execution(* org.openqa.selenium.SearchContext." - + "findElement(..)) || " - + "execution(* org.openqa.selenium.SearchContext.findElements(..))"; - private static final String EXECUTION_CLICK = "execution(* org.openqa.selenium.WebElement.click(..))"; - private static final String EXECUTION_CHANGE_VALUE = "execution(* org.openqa.selenium.WebElement." - + "sendKeys(..)) || " - + "execution(* org.openqa.selenium.WebElement.clear(..)) || " - + "execution(* io.appium.java_client.android.AndroidElement.replaceValue(..)) || " - + "execution(* io.appium.java_client.MobileElement.setValue(..))"; - private static final String EXECUTION_SCRIPT = "execution(* org.openqa.selenium.JavascriptExecutor." - + "executeScript(..)) || " - + "execution(* org.openqa.selenium.JavascriptExecutor.executeAsyncScript(..))"; - private static final String EXECUTION_ALERT_ACCEPT = "execution(* org.openqa.selenium.Alert." - + "accept(..))"; - private static final String EXECUTION_ALERT_DISMISS = "execution(* org.openqa.selenium.Alert." - + "dismiss(..))"; - private static final String EXECUTION_ALERT_SEND_KEYS = "execution(* org.openqa.selenium.Alert." - + "sendKeys(..))"; - private static final String EXECUTION_WINDOW_SET_SIZE = "execution(* org.openqa.selenium." - + "WebDriver.Window.setSize(..))"; - private static final String EXECUTION_WINDOW_SET_POSITION = "execution(* org.openqa.selenium.WebDriver." - + "Window.setPosition(..))"; - private static final String EXECUTION_WINDOW_MAXIMIZE = "execution(* org.openqa.selenium.WebDriver." - + "Window.maximize(..))"; - private static final String EXECUTION_ROTATE = "execution(* org.openqa.selenium.Rotatable" - + ".rotate(..))"; - private static final String EXECUTION_CONTEXT = "execution(* org.openqa.selenium.ContextAware." - + "context(..))"; - private static final String EXECUTION_SWITCH_TO_WINDOW = "execution(* org.openqa.selenium.WebDriver.TargetLocator" - + ".window(..))"; - private static final String EXECUTION_TAKE_SCREENSHOT_AS = "execution(* org.openqa.selenium.TakesScreenshot" - + ".getScreenshotAs(..))"; - private static final String AROUND = "execution(* org.openqa.selenium.WebDriver.*(..)) || " - + "execution(* org.openqa.selenium.WebElement.*(..)) || " - + "execution(* org.openqa.selenium.WebDriver.Navigation.*(..)) || " - + "execution(* org.openqa.selenium.WebDriver.Options.*(..)) || " - + "execution(* org.openqa.selenium.WebDriver.TargetLocator.*(..)) || " - + "execution(* org.openqa.selenium.WebDriver.TargetLocator.*(..)) || " - + "execution(* org.openqa.selenium.JavascriptExecutor.*(..)) || " - + "execution(* org.openqa.selenium.ContextAware.*(..)) || " - + "execution(* org.openqa.selenium.WebDriver.Window.*(..)) || " - + "execution(* io.appium.java_client.android.AndroidElement.*(..)) || " - + "execution(* io.appium.java_client.ios.IOSElement.*(..)) || " - + "execution(* io.appium.java_client.android.AndroidDriver.*(..)) || " - + "execution(* io.appium.java_client.ios.IOSDriver.*(..)) || " - + "execution(* io.appium.java_client.AppiumDriver.*(..)) || " - + "execution(* io.appium.java_client.MobileElement.*(..)) || " - + "execution(* org.openqa.selenium.remote.RemoteWebDriver.*(..)) || " - + "execution(* org.openqa.selenium.remote.RemoteWebElement.*(..)) || " - + "execution(* org.openqa.selenium.Alert.*(..)) || " - + "execution(* org.openqa.selenium.TakesScreenshot.*(..))"; - - private final AbstractApplicationContext context; - private final WebDriver driver; - private final DefaultListener listener = new DefaultListener(); - - private static Throwable getRootCause(Throwable thrown) { - Class throwableClass = thrown.getClass(); - - if (!InvocationTargetException.class.equals(throwableClass) && !RuntimeException.class.equals(throwableClass)) { - return thrown; - } - if (thrown.getCause() != null) { - return getRootCause(thrown.getCause()); - } - return thrown; - } - - private static Class getClassForProxy(Class classOfObject) { - Class returnStatement = null; - for (Class c : listenable) { - if (!c.isAssignableFrom(classOfObject)) { - continue; - } - returnStatement = c; - } - return returnStatement; - } - - DefaultAspect(AbstractApplicationContext context, WebDriver driver) { - this.context = context; - this.driver = driver; - } - - private Object transformToListenable(Object toBeTransformed) { - if (toBeTransformed == null) { - return null; - } - - Object result = toBeTransformed; - if (getClassForProxy(toBeTransformed.getClass()) != null) { - result = context.getBean(COMPONENT_BEAN, toBeTransformed); - } - return result; - } - - private List returnProxyList(List originalList) { - try { - List proxyList = new ArrayList<>(); - for (Object o : originalList) { - if (getClassForProxy(o.getClass()) == null) { - proxyList.add(o); - } else { - proxyList.add(context.getBean(COMPONENT_BEAN, o)); - } - } - return proxyList; - } catch (Exception e) { - throw e; - } - - } - - public void add(Collection listeners) { - listener.add(listeners); - } - - @Before(EXECUTION_NAVIGATION_TO) - public void beforeNavigateTo(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeNavigateTo(String.valueOf(joinPoint.getArgs()[0]), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_NAVIGATION_TO) - public void afterNavigateTo(JoinPoint joinPoint) throws Throwable { - try { - listener.afterNavigateTo(String.valueOf(joinPoint.getArgs()[0]), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_NAVIGATION_BACK) - public void beforeNavigateBack(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeNavigateBack(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_NAVIGATION_BACK) - public void afterNavigateBack(JoinPoint joinPoint) throws Throwable { - try { - listener.afterNavigateBack(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_NAVIGATION_FORWARD) - public void beforeNavigateForward(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeNavigateForward(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_NAVIGATION_FORWARD) - public void afterNavigateForward(JoinPoint joinPoint) throws Throwable { - try { - listener.afterNavigateForward(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_NAVIGATION_REFRESH) - public void beforeNavigateRefresh(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeNavigateRefresh(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_NAVIGATION_REFRESH) - public void afterNavigateRefresh(JoinPoint joinPoint) throws Throwable { - try { - listener.afterNavigateRefresh(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @SuppressWarnings("unchecked") - private T castArgument(JoinPoint joinPoint, int argIndex) { - return (T) joinPoint.getArgs()[argIndex]; - } - - @SuppressWarnings("unchecked") - private T castTarget(JoinPoint joinPoint) { - return (T) joinPoint.getTarget(); - } - - @Before(EXECUTION_SEARCH) - public void beforeFindBy(JoinPoint joinPoint) throws Throwable { - try { - Object target = joinPoint.getTarget(); - if (!WebElement.class.isAssignableFrom(target.getClass())) { - listener.beforeFindBy(castArgument(joinPoint, 0), null, driver); - } else { - listener.beforeFindBy(castArgument(joinPoint, 0), - castTarget(joinPoint), driver); - } - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_SEARCH) - public void afterFindBy(JoinPoint joinPoint) throws Throwable { - try { - Object target = joinPoint.getTarget(); - if (!WebElement.class.isAssignableFrom(target.getClass())) { - listener.afterFindBy(castArgument(joinPoint, 0), null, driver); - } else { - listener.afterFindBy(castArgument(joinPoint, 0), - castTarget(joinPoint), driver); - } - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_CLICK) - public void beforeClickOn(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeClickOn(castTarget(joinPoint), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_CLICK) - public void afterClickOn(JoinPoint joinPoint) throws Throwable { - try { - listener.afterClickOn(castTarget(joinPoint), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_CHANGE_VALUE) - public void beforeChangeValueOf(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeChangeValueOf(castTarget(joinPoint), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_CHANGE_VALUE) - public void afterChangeValueOf(JoinPoint joinPoint) throws Throwable { - try { - listener.afterChangeValueOf(castTarget(joinPoint), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_SCRIPT) - public void beforeScript(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeScript(String.valueOf(joinPoint.getArgs()[0]), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_SCRIPT) - public void afterScript(JoinPoint joinPoint) throws Throwable { - try { - listener.afterScript(String.valueOf(joinPoint.getArgs()[0]), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_ALERT_ACCEPT) - public void beforeAlertAccept(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeAlertAccept(driver, castTarget(joinPoint)); - listener.beforeAlertAccept(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_ALERT_ACCEPT) - public void afterAlertAccept(JoinPoint joinPoint) throws Throwable { - try { - listener.afterAlertAccept(driver, castTarget(joinPoint)); - listener.afterAlertAccept(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_ALERT_DISMISS) - public void beforeAlertDismiss(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeAlertDismiss(driver, castTarget(joinPoint)); - listener.beforeAlertDismiss(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_ALERT_DISMISS) - public void afterAlertDismiss(JoinPoint joinPoint) throws Throwable { - try { - listener.afterAlertDismiss(driver, castTarget(joinPoint)); - listener.afterAlertDismiss(driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_ALERT_SEND_KEYS) - public void beforeAlertSendKeys(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeAlertSendKeys(driver, castTarget(joinPoint), - String.valueOf(joinPoint.getArgs()[0])); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_ALERT_SEND_KEYS) - public void afterAlertSendKeys(JoinPoint joinPoint) throws Throwable { - try { - listener.afterAlertSendKeys(driver, castTarget(joinPoint), - String.valueOf(joinPoint.getArgs()[0])); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_WINDOW_SET_SIZE) - public void beforeWindowIsResized(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeWindowChangeSize(driver, - castTarget(joinPoint), castArgument(joinPoint, 0)); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_WINDOW_SET_SIZE) - public void afterWindowIsResized(JoinPoint joinPoint) throws Throwable { - try { - listener.afterWindowChangeSize(driver, castTarget(joinPoint), - castArgument(joinPoint, 0)); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_WINDOW_SET_POSITION) - public void beforeWindowIsMoved(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeWindowIsMoved(driver, castTarget(joinPoint), - castArgument(joinPoint, 0)); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_WINDOW_SET_POSITION) - public void afterWindowIsMoved(JoinPoint joinPoint) throws Throwable { - try { - listener.afterWindowIsMoved(driver, castTarget(joinPoint), - castArgument(joinPoint, 0)); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_WINDOW_MAXIMIZE) - public void beforeMaximization(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeWindowIsMaximized(driver, castTarget(joinPoint)); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_WINDOW_MAXIMIZE) - public void afterMaximization(JoinPoint joinPoint) throws Throwable { - try { - listener.afterWindowIsMaximized(driver, castTarget(joinPoint)); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_SWITCH_TO_WINDOW) - public void beforeSwitchToWindow(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeSwitchToWindow(castArgument(joinPoint, 0), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @After(EXECUTION_SWITCH_TO_WINDOW) - public void afterSwitchToWindow(JoinPoint joinPoint) throws Throwable { - try { - listener.afterSwitchToWindow(castArgument(joinPoint, 0), driver); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_TAKE_SCREENSHOT_AS) - public void beforeTakeScreenShot(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeGetScreenshotAs(castArgument(joinPoint, 0)); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @AfterReturning(value = EXECUTION_TAKE_SCREENSHOT_AS, returning = "result") - public void afterTakeScreenShot(JoinPoint joinPoint, Object result) throws Throwable { - try { - listener.afterGetScreenshotAs(castArgument(joinPoint, 0), result); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_ROTATE) - public void beforeRotation(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeRotation(driver, castArgument(joinPoint, 0)); - } catch (Throwable t) { - throw getRootCause(t); - } - - } - - @After(EXECUTION_ROTATE) - public void afterRotation(JoinPoint joinPoint) throws Throwable { - try { - listener.afterRotation(driver, castArgument(joinPoint, 0)); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Before(EXECUTION_CONTEXT) - public void beforeSwitchingToContext(JoinPoint joinPoint) throws Throwable { - try { - listener.beforeSwitchingToContext(driver, String.valueOf(joinPoint.getArgs()[0])); - } catch (Throwable t) { - throw getRootCause(t); - } - - } - - @After(EXECUTION_CONTEXT) - public void afterSwitchingToContextn(JoinPoint joinPoint) throws Throwable { - try { - listener.afterSwitchingToContext(driver, String.valueOf(joinPoint.getArgs()[0])); - } catch (Throwable t) { - throw getRootCause(t); - } - } - - @Around(AROUND) - public Object doAround(ProceedingJoinPoint point) throws Throwable { - Throwable t = null; - Object result = null; - try { - result = point.proceed(); - } catch (Throwable e) { - t = e; - } - if (t != null) { - Throwable rootCause = getRootCause(t); - listener.onException(rootCause, driver); - throw rootCause; - } - - if (result == null) { // maybe it was "void" - return null; - } - if (List.class.isAssignableFrom(result.getClass())) { - return returnProxyList((List) (result)); - } - - return transformToListenable(result); - } -} diff --git a/src/main/java/io/appium/java_client/events/DefaultBeanConfiguration.java b/src/main/java/io/appium/java_client/events/DefaultBeanConfiguration.java deleted file mode 100644 index ac2dd1581..000000000 --- a/src/main/java/io/appium/java_client/events/DefaultBeanConfiguration.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.WebDriver; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.context.annotation.Scope; -import org.springframework.context.support.AbstractApplicationContext; - -import java.util.ArrayList; -import java.util.List; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -@Configuration -@EnableAspectJAutoProxy(proxyTargetClass = true) -class DefaultBeanConfiguration { - public static final String LISTENABLE_OBJECT = "object"; - public static final String COMPONENT_BEAN = "component"; - - protected final List listeners = new ArrayList<>(); - protected WebDriver driver; - protected AbstractApplicationContext context; - - @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) - @Bean(name = LISTENABLE_OBJECT) - public T init(T t, WebDriver driver, List listeners, - AbstractApplicationContext context) { - this.driver = driver; - this.listeners.addAll(listeners); - this.context = context; - return t; - } - - @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) - @Bean(name = COMPONENT_BEAN) - public T getComponent(T t) { - return t; - } - - @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) - @Bean(name = "defaultAspect") - public DefaultAspect getAspect() { - DefaultAspect aspect = new DefaultAspect(context, driver); - aspect.add(listeners); - return aspect; - } -} diff --git a/src/main/java/io/appium/java_client/events/DefaultListener.java b/src/main/java/io/appium/java_client/events/DefaultListener.java deleted file mode 100644 index 87c2cf15d..000000000 --- a/src/main/java/io/appium/java_client/events/DefaultListener.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events; - -import io.appium.java_client.events.api.Listener; -import io.appium.java_client.events.api.general.AlertEventListener; -import io.appium.java_client.events.api.general.AppiumWebDriverEventListener; -import io.appium.java_client.events.api.general.ElementEventListener; -import io.appium.java_client.events.api.general.JavaScriptEventListener; -import io.appium.java_client.events.api.general.ListensToException; -import io.appium.java_client.events.api.general.NavigationEventListener; -import io.appium.java_client.events.api.general.SearchingEventListener; -import io.appium.java_client.events.api.general.WindowEventListener; -import io.appium.java_client.events.api.mobile.ContextEventListener; -import io.appium.java_client.events.api.mobile.RotationEventListener; -import org.openqa.selenium.Alert; -import org.openqa.selenium.By; -import org.openqa.selenium.Dimension; -import org.openqa.selenium.OutputType; -import org.openqa.selenium.Point; -import org.openqa.selenium.ScreenOrientation; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.events.WebDriverEventListener; - -import java.lang.reflect.Proxy; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -class DefaultListener - implements Listener, AppiumWebDriverEventListener, ListensToException, SearchingEventListener, - NavigationEventListener, JavaScriptEventListener, ElementEventListener, AlertEventListener, - WindowEventListener, ContextEventListener, RotationEventListener { - - private final List listeners = new ArrayList<>(); - - private Object dispatcher = Proxy.newProxyInstance(Listener.class.getClassLoader(), - new Class[] {AlertEventListener.class, ContextEventListener.class, - ElementEventListener.class, JavaScriptEventListener.class, ListensToException.class, - NavigationEventListener.class, RotationEventListener.class, - SearchingEventListener.class, WindowEventListener.class, WebDriverEventListener.class}, - new ListenerInvocationHandler(listeners)); - - @Override public void beforeNavigateTo(String url, WebDriver driver) { - ((NavigationEventListener) dispatcher).beforeNavigateTo(url, driver); - } - - @Override public void afterNavigateTo(String url, WebDriver driver) { - ((NavigationEventListener) dispatcher).afterNavigateTo(url, driver); - } - - @Override public void beforeNavigateBack(WebDriver driver) { - ((NavigationEventListener) dispatcher).beforeNavigateBack(driver); - } - - @Override public void afterNavigateBack(WebDriver driver) { - ((NavigationEventListener) dispatcher).afterNavigateBack(driver); - } - - @Override public void beforeNavigateForward(WebDriver driver) { - ((NavigationEventListener) dispatcher).beforeNavigateForward(driver); - } - - @Override public void afterNavigateForward(WebDriver driver) { - ((NavigationEventListener) dispatcher).afterNavigateForward(driver); - } - - @Override public void beforeNavigateRefresh(WebDriver driver) { - ((NavigationEventListener) dispatcher).beforeNavigateRefresh(driver); - } - - @Override public void afterNavigateRefresh(WebDriver driver) { - ((NavigationEventListener) dispatcher).afterNavigateRefresh(driver); - } - - @Override public void beforeFindBy(By by, WebElement element, WebDriver driver) { - ((SearchingEventListener) dispatcher).beforeFindBy(by, element, driver); - } - - @Override public void afterFindBy(By by, WebElement element, WebDriver driver) { - ((SearchingEventListener) dispatcher).afterFindBy(by, element, driver); - } - - @Override public void beforeClickOn(WebElement element, WebDriver driver) { - ((ElementEventListener) dispatcher).beforeClickOn(element, driver); - } - - @Override public void afterClickOn(WebElement element, WebDriver driver) { - ((ElementEventListener) dispatcher).afterClickOn(element, driver); - } - - @Override public void beforeChangeValueOf(WebElement element, WebDriver driver) { - ((ElementEventListener) dispatcher).beforeChangeValueOf(element, driver); - } - - @Override public void beforeChangeValueOf(WebElement element, WebDriver driver, - CharSequence[] keysToSend) { - ((ElementEventListener) dispatcher).beforeChangeValueOf(element, driver, keysToSend); - } - - @Override public void afterChangeValueOf(WebElement element, WebDriver driver) { - ((ElementEventListener) dispatcher).afterChangeValueOf(element, driver); - } - - @Override public void afterChangeValueOf(WebElement element, WebDriver driver, - CharSequence[] keysToSend) { - ((ElementEventListener) dispatcher).afterChangeValueOf(element, driver, keysToSend); - } - - @Override public void beforeScript(String script, WebDriver driver) { - ((JavaScriptEventListener) dispatcher).beforeScript(script, driver); - } - - @Override public void afterScript(String script, WebDriver driver) { - ((JavaScriptEventListener) dispatcher).afterScript(script, driver); - } - - @Override public void onException(Throwable throwable, WebDriver driver) { - ((ListensToException) dispatcher).onException(throwable, driver); - } - - @Override - public void beforeGetScreenshotAs(OutputType target) { - ((WebDriverEventListener) dispatcher).beforeGetScreenshotAs(target); - } - - @Override - public void afterGetScreenshotAs(OutputType target, X screenshot) { - ((WebDriverEventListener) dispatcher).afterGetScreenshotAs(target, screenshot); - } - - @Override - public void beforeGetText(WebElement element, WebDriver driver) { - ((ElementEventListener) dispatcher).beforeGetText(element, driver); - } - - @Override - public void afterGetText(WebElement element, WebDriver driver, String text) { - ((ElementEventListener) dispatcher).afterGetText(element, driver, text); - } - - public void add(Collection listeners) { - this.listeners.addAll(listeners); - } - - @Override public void beforeAlertAccept(WebDriver driver, Alert alert) { - ((AlertEventListener) dispatcher).beforeAlertAccept(driver, alert); - } - - @Override - public void beforeAlertAccept(WebDriver driver) { - ((WebDriverEventListener) dispatcher).beforeAlertAccept(driver); - } - - @Override public void afterAlertAccept(WebDriver driver, Alert alert) { - ((AlertEventListener) dispatcher).afterAlertAccept(driver, alert); - } - - @Override - public void afterAlertAccept(WebDriver driver) { - ((WebDriverEventListener) dispatcher).afterAlertAccept(driver); - } - - @Override public void afterAlertDismiss(WebDriver driver, Alert alert) { - ((AlertEventListener) dispatcher).afterAlertDismiss(driver, alert); - } - - @Override - public void afterAlertDismiss(WebDriver driver) { - ((WebDriverEventListener) dispatcher).afterAlertDismiss(driver); - } - - @Override public void beforeAlertDismiss(WebDriver driver, Alert alert) { - ((AlertEventListener) dispatcher).beforeAlertDismiss(driver, alert); - } - - @Override - public void beforeAlertDismiss(WebDriver driver) { - ((WebDriverEventListener) dispatcher).beforeAlertDismiss(driver); - } - - @Override public void beforeAlertSendKeys(WebDriver driver, Alert alert, String keys) { - ((AlertEventListener) dispatcher).beforeAlertSendKeys(driver, alert, keys); - } - - @Override public void afterAlertSendKeys(WebDriver driver, Alert alert, String keys) { - ((AlertEventListener) dispatcher).afterAlertSendKeys(driver, alert, keys); - } - - @Override public void beforeWindowChangeSize(WebDriver driver, WebDriver.Window window, - Dimension targetSize) { - ((WindowEventListener) dispatcher).beforeWindowChangeSize(driver, window, targetSize); - } - - @Override public void afterWindowChangeSize(WebDriver driver, WebDriver.Window window, - Dimension targetSize) { - ((WindowEventListener) dispatcher).afterWindowChangeSize(driver, window, targetSize); - } - - @Override - public void beforeWindowIsMoved(WebDriver driver, WebDriver.Window window, Point targetPoint) { - ((WindowEventListener) dispatcher).beforeWindowIsMoved(driver, window, targetPoint); - } - - @Override - public void afterWindowIsMoved(WebDriver driver, WebDriver.Window window, Point targetPoint) { - ((WindowEventListener) dispatcher).afterWindowIsMoved(driver, window, targetPoint); - } - - @Override public void beforeWindowIsMaximized(WebDriver driver, WebDriver.Window window) { - ((WindowEventListener) dispatcher).beforeWindowIsMaximized(driver, window); - } - - @Override public void afterWindowIsMaximized(WebDriver driver, WebDriver.Window window) { - ((WindowEventListener) dispatcher).afterWindowIsMaximized(driver, window); - } - - @Override - public void beforeSwitchToWindow(String windowName, WebDriver driver) { - ((WebDriverEventListener) dispatcher).beforeSwitchToWindow(windowName, driver); - } - - @Override - public void afterSwitchToWindow(String windowName, WebDriver driver) { - ((WebDriverEventListener) dispatcher).afterSwitchToWindow(windowName, driver); - } - - @Override public void beforeSwitchingToContext(WebDriver driver, String context) { - ((ContextEventListener) dispatcher).beforeSwitchingToContext(driver, context); - } - - @Override public void afterSwitchingToContext(WebDriver driver, String context) { - ((ContextEventListener) dispatcher).afterSwitchingToContext(driver, context); - } - - @Override public void beforeRotation(WebDriver driver, ScreenOrientation orientation) { - ((RotationEventListener) dispatcher).beforeRotation(driver, orientation); - } - - @Override public void afterRotation(WebDriver driver, ScreenOrientation orientation) { - ((RotationEventListener) dispatcher).afterRotation(driver, orientation); - } -} diff --git a/src/main/java/io/appium/java_client/events/EventFiringObjectFactory.java b/src/main/java/io/appium/java_client/events/EventFiringObjectFactory.java deleted file mode 100644 index 867251ccd..000000000 --- a/src/main/java/io/appium/java_client/events/EventFiringObjectFactory.java +++ /dev/null @@ -1,77 +0,0 @@ -package io.appium.java_client.events; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.WebDriver; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.support.AbstractApplicationContext; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.ServiceLoader; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public class EventFiringObjectFactory { - - /** - * This method makes an event firing object. - * - * @param t an original {@link Object} that is - * supposed to be listenable - * @param driver an instance of {@link org.openqa.selenium.WebDriver} - * @param listeners is a collection of {@link io.appium.java_client.events.api.Listener} that - * is supposed to be used for the event firing - * @param T - * @return an {@link Object} that fires events - */ - @SuppressWarnings("unchecked") - public static T getEventFiringObject(T t, WebDriver driver, Collection listeners) { - final List listenerList = new ArrayList<>(); - - for (Listener listener : ServiceLoader.load( - Listener.class)) { - listenerList.add(listener); - } - - listeners.stream().filter(listener -> !listenerList.contains(listener)).forEach(listenerList::add); - - AbstractApplicationContext context = new AnnotationConfigApplicationContext( - DefaultBeanConfiguration.class); - return (T) context.getBean( - DefaultBeanConfiguration.LISTENABLE_OBJECT, t, driver, listenerList, context); - } - - /** - * This method makes an event firing object. - * - * @param t an original {@link Object} that is - * supposed to be listenable - * @param driver an instance of {@link org.openqa.selenium.WebDriver} - * @param T - * @return an {@link Object} that fires events - */ - public static T getEventFiringObject(T t, WebDriver driver) { - return getEventFiringObject(t, driver, Collections.emptyList()); - } - - /** - * This method makes an event firing object. - * - * @param t an original {@link Object} that is - * supposed to be listenable - * @param driver an instance of {@link org.openqa.selenium.WebDriver} - * @param listeners is an array of {@link io.appium.java_client.events.api.Listener} that - * is supposed to be used for the event firing - * - * @param T - * @return an instance of {@link org.openqa.selenium.WebDriver} that fires events - */ - public static T getEventFiringObject(T t, WebDriver driver, Listener ... listeners) { - return getEventFiringObject(t, driver, Arrays.asList(listeners)); - } -} diff --git a/src/main/java/io/appium/java_client/events/EventFiringWebDriverFactory.java b/src/main/java/io/appium/java_client/events/EventFiringWebDriverFactory.java deleted file mode 100644 index f0d255772..000000000 --- a/src/main/java/io/appium/java_client/events/EventFiringWebDriverFactory.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events; - -import static io.appium.java_client.events.EventFiringObjectFactory.getEventFiringObject; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.WebDriver; - -import java.util.Collection; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public class EventFiringWebDriverFactory { - - /** - * This method makes an event firing instance of {@link org.openqa.selenium.WebDriver}. - * - * @param driver an original instance of {@link org.openqa.selenium.WebDriver} that is - * supposed to be listenable - * @param T - * @return an instance of {@link org.openqa.selenium.WebDriver} that fires events - */ - public static T getEventFiringWebDriver(T driver) { - return getEventFiringObject(driver, driver); - } - - /** - * This method makes an event firing instance of {@link org.openqa.selenium.WebDriver}. - * - * @param driver an original instance of {@link org.openqa.selenium.WebDriver} that is - * supposed to be listenable - * @param listeners is a set of {@link io.appium.java_client.events.api.Listener} that - * is supposed to be used for the event firing - * @param T - * @return an instance of {@link org.openqa.selenium.WebDriver} that fires events - */ - public static T getEventFiringWebDriver(T driver, Listener ... listeners) { - return getEventFiringObject(driver, driver, listeners); - } - - /** - * This method makes an event firing instance of {@link org.openqa.selenium.WebDriver}. - * - * @param driver an original instance of {@link org.openqa.selenium.WebDriver} that is - * supposed to be listenable - * @param listeners is a collection of {@link io.appium.java_client.events.api.Listener} that - * is supposed to be used for the event firing - * @param T - * @return an instance of {@link org.openqa.selenium.WebDriver} that fires events - */ - public static T getEventFiringWebDriver(T driver, Collection listeners) { - return getEventFiringObject(driver, driver, listeners); - } -} diff --git a/src/main/java/io/appium/java_client/events/ListenerInvocationHandler.java b/src/main/java/io/appium/java_client/events/ListenerInvocationHandler.java deleted file mode 100644 index 7fe31125d..000000000 --- a/src/main/java/io/appium/java_client/events/ListenerInvocationHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.support.events.WebDriverEventListener; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.util.List; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -class ListenerInvocationHandler implements InvocationHandler { - - private final List listeners; - - ListenerInvocationHandler(List listeners) { - this.listeners = listeners; - } - - private Method findElementInWebDriverEventListener(Method m) { - try { - return WebDriverEventListener.class.getMethod(m.getName(), m.getParameterTypes()); - } catch (NoSuchMethodException e) { - return null; - } - } - - @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - for (Listener l: listeners) { - boolean isInvoked = false; - if (method.getDeclaringClass().isAssignableFrom(l.getClass())) { - method.invoke(l, args); - isInvoked = true; - } - - if (isInvoked) { - continue; - } - - Method webDriverEventListenerMethod = findElementInWebDriverEventListener(method); - if (webDriverEventListenerMethod != null - && WebDriverEventListener.class.isAssignableFrom(l.getClass())) { - webDriverEventListenerMethod.invoke(l, args); - } - } - return null; - } -} diff --git a/src/main/java/io/appium/java_client/events/api/Listener.java b/src/main/java/io/appium/java_client/events/api/Listener.java deleted file mode 100644 index aeb7e7986..000000000 --- a/src/main/java/io/appium/java_client/events/api/Listener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api; - -/** - * This interface just marks event listeners. - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface Listener { -} diff --git a/src/main/java/io/appium/java_client/events/api/general/AlertEventListener.java b/src/main/java/io/appium/java_client/events/api/general/AlertEventListener.java deleted file mode 100644 index a9895b758..000000000 --- a/src/main/java/io/appium/java_client/events/api/general/AlertEventListener.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.general; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.Alert; -import org.openqa.selenium.WebDriver; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface AlertEventListener extends Listener { - - /** - * This action will be performed each time before {@link Alert#accept()}. - * - * @param driver WebDriver - * @param alert {@link Alert} which is being accepted - */ - void beforeAlertAccept(WebDriver driver, Alert alert); - - /** - * This action will be performed each time after {@link Alert#accept()}. - * - * @param driver WebDriver - * @param alert {@link Alert} which has been accepted - */ - void afterAlertAccept(WebDriver driver, Alert alert); - - /** - * This action will be performed each time before {@link Alert#dismiss()}. - * - * @param driver WebDriver - * @param alert {@link Alert} which which is being dismissed - */ - void afterAlertDismiss(WebDriver driver, Alert alert); - - /** - * This action will be performed each time after {@link Alert#dismiss()}. - * - * @param driver WebDriver - * @param alert {@link Alert} which has been dismissed - */ - void beforeAlertDismiss(WebDriver driver, Alert alert); - - /** - * This action will be performed each time before {@link Alert#sendKeys(String)}. - * - * @param driver WebDriver - * @param alert {@link Alert} which is receiving keys - * @param keys Keys which are being sent - */ - void beforeAlertSendKeys(WebDriver driver, Alert alert, String keys); - - /** - * This action will be performed each time after {@link Alert#sendKeys(String)}. - * - * @param driver WebDriver - * @param alert {@link Alert} which has received keys - * @param keys Keys which have been sent - */ - void afterAlertSendKeys(WebDriver driver, Alert alert, String keys); -} diff --git a/src/main/java/io/appium/java_client/events/api/general/AppiumWebDriverEventListener.java b/src/main/java/io/appium/java_client/events/api/general/AppiumWebDriverEventListener.java deleted file mode 100644 index d232c207e..000000000 --- a/src/main/java/io/appium/java_client/events/api/general/AppiumWebDriverEventListener.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.general; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.support.events.WebDriverEventListener; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface AppiumWebDriverEventListener extends Listener, WebDriverEventListener, ListensToException, - SearchingEventListener, NavigationEventListener, - JavaScriptEventListener, ElementEventListener { -} diff --git a/src/main/java/io/appium/java_client/events/api/general/ElementEventListener.java b/src/main/java/io/appium/java_client/events/api/general/ElementEventListener.java deleted file mode 100644 index 6b5d72935..000000000 --- a/src/main/java/io/appium/java_client/events/api/general/ElementEventListener.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.general; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface ElementEventListener extends Listener { - /** - * Called before {@link WebElement#click WebElement.click()}. - * - * @param driver WebDriver - * @param element the WebElement being used for the action - */ - void beforeClickOn(WebElement element, WebDriver driver); - - /** - * Called after {@link WebElement#click WebElement.click()}. - * Not called, if an exception is thrown. - * - * @param driver WebDriver - * @param element the WebElement being used for the action - */ - void afterClickOn(WebElement element, WebDriver driver); - - /** - * Called before {@link WebElement#clear WebElement.clear()}, - * {@link WebElement#sendKeys WebElement.sendKeys(...)}. - * - * @param driver WebDriver - * @param element the WebElement being used for the action - */ - void beforeChangeValueOf(WebElement element, WebDriver driver); - - /** - * Called before {@link WebElement#clear WebElement.clear()}, - * {@link WebElement#sendKeys WebElement.sendKeys(...)}. - * - * @param driver WebDriver - * @param element the WebElement being used for the action - * @param keysToSend character sequence to send to the element - */ - void beforeChangeValueOf(WebElement element, WebDriver driver, CharSequence[] keysToSend); - - /** - * Called after {@link WebElement#clear WebElement.clear()}, - * {@link WebElement#sendKeys WebElement.sendKeys(...)}. - * Not called, if an exception is thrown. - * - * @param driver WebDriver - * @param element the WebElement being used for the action - */ - void afterChangeValueOf(WebElement element, WebDriver driver); - - /** - * Called after {@link WebElement#clear WebElement.clear()}, - * {@link WebElement#sendKeys WebElement.sendKeys(...)} . - * Not called, if an exception is thrown. - * - * @param driver WebDriver - * @param element the WebElement being used for the action - * @param keysToSend character sequence to send to the element - */ - void afterChangeValueOf(WebElement element, WebDriver driver, CharSequence[] keysToSend); - - /** - * Called before {@link WebElement#getText()} method is being called. - * - * @param element - {@link WebElement} against which call is being made - * @param driver - instance of {@link WebDriver} - */ - void beforeGetText(WebElement element, WebDriver driver); - - /** - * Called right after {@link WebElement#getText()} method is being called. - * - * @param element - {@link WebElement} against which call is being made - * @param driver - instance of {@link WebDriver} - * @param text - {@link String} object extracted from respective {@link WebElement} - */ - void afterGetText(WebElement element, WebDriver driver, String text); -} diff --git a/src/main/java/io/appium/java_client/events/api/general/JavaScriptEventListener.java b/src/main/java/io/appium/java_client/events/api/general/JavaScriptEventListener.java deleted file mode 100644 index 25556a961..000000000 --- a/src/main/java/io/appium/java_client/events/api/general/JavaScriptEventListener.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.general; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.WebDriver; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface JavaScriptEventListener extends Listener { - /** - * Called before - * {@link org.openqa.selenium.JavascriptExecutor#executeScript(String, Object[]) }. - * - * @param driver WebDriver - * @param script the script to be executed - */ - void beforeScript(String script, WebDriver driver); - - /** - * Called after - * {@link org.openqa.selenium.remote.RemoteWebDriver#executeScript(String, Object[]) }. - * Not called if an exception is thrown - * - * @param driver WebDriver - * @param script the script that was executed - */ - void afterScript(String script, WebDriver driver); -} diff --git a/src/main/java/io/appium/java_client/events/api/general/ListensToException.java b/src/main/java/io/appium/java_client/events/api/general/ListensToException.java deleted file mode 100644 index a6f3b4b3d..000000000 --- a/src/main/java/io/appium/java_client/events/api/general/ListensToException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.general; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.WebDriver; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface ListensToException extends Listener { - /** - * Called whenever an exception would be thrown. - * @param throwable the exception that will be thrown - * @param driver WebDriver - */ - void onException(Throwable throwable, WebDriver driver); -} diff --git a/src/main/java/io/appium/java_client/events/api/general/NavigationEventListener.java b/src/main/java/io/appium/java_client/events/api/general/NavigationEventListener.java deleted file mode 100644 index 9b2b33e39..000000000 --- a/src/main/java/io/appium/java_client/events/api/general/NavigationEventListener.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.general; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.WebDriver; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface NavigationEventListener extends Listener { - - /** - * Called before {@link org.openqa.selenium.WebDriver#get get(String url)} - * respectively {@link org.openqa.selenium.WebDriver.Navigation#to - * navigate().to(String url)}. - * - * @param url URL - * @param driver WebDriver - */ - void beforeNavigateTo(String url, WebDriver driver); - - /** - * Called after {@link org.openqa.selenium.WebDriver#get get(String url)} - * respectively {@link org.openqa.selenium.WebDriver.Navigation#to - * navigate().to(String url)}. Not called, if an exception is thrown. - * - * @param url URL - * @param driver WebDriver - */ - void afterNavigateTo(String url, WebDriver driver); - - /** - * Called before {@link org.openqa.selenium.WebDriver.Navigation#back - * navigate().back()}. - * - * @param driver WebDriver - */ - void beforeNavigateBack(WebDriver driver); - - /** - * Called after {@link org.openqa.selenium.WebDriver.Navigation - * navigate().back()}. Not called, if an exception is thrown. - * - * @param driver WebDriver - */ - void afterNavigateBack(WebDriver driver); - - /** - * Called before {@link org.openqa.selenium.WebDriver.Navigation#forward - * navigate().forward()}. - * - * @param driver WebDriver - */ - void beforeNavigateForward(WebDriver driver); - - /** - * Called after {@link org.openqa.selenium.WebDriver.Navigation#forward - * navigate().forward()}. Not called, if an exception is thrown. - * - * @param driver WebDriver - */ - void afterNavigateForward(WebDriver driver); - - /** - * Called before {@link org.openqa.selenium.WebDriver.Navigation#refresh navigate().refresh()}. - * - * @param driver WebDriver - */ - void beforeNavigateRefresh(WebDriver driver); - - /** - * Called after {@link org.openqa.selenium.WebDriver.Navigation#refresh navigate().refresh()}. - * - * @param driver WebDriver - */ - void afterNavigateRefresh(WebDriver driver); -} diff --git a/src/main/java/io/appium/java_client/events/api/general/SearchingEventListener.java b/src/main/java/io/appium/java_client/events/api/general/SearchingEventListener.java deleted file mode 100644 index 03be74a3e..000000000 --- a/src/main/java/io/appium/java_client/events/api/general/SearchingEventListener.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.general; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface SearchingEventListener extends Listener { - - /** - * Called before {@link org.openqa.selenium.WebDriver#findElement WebDriver.findElement(...)}, - * or - * {@link org.openqa.selenium.WebDriver#findElements WebDriver.findElements(...)}, or - * {@link org.openqa.selenium.WebElement#findElement WebElement.findElement(...)}, or - * {@link org.openqa.selenium.WebElement#findElement WebElement.findElements(...)}. - * - * @param element will be null, if a find method of WebDriver - * is called. - * @param by locator being used - * @param driver WebDriver - */ - void beforeFindBy(By by, WebElement element, WebDriver driver); - - /** - * Called after {@link org.openqa.selenium.WebDriver#findElement WebDriver.findElement(...)}, - * or - * {@link org.openqa.selenium.WebDriver#findElements WebDriver.findElements(...)}, or - * {@link org.openqa.selenium.WebElement#findElement WebElement.findElement(...)}, or - * {@link org.openqa.selenium.WebElement#findElement WebElement.findElements(...)}. - * - * @param element will be null, if a find method of WebDriver - * is called. - * @param by locator being used - * @param driver WebDriver - */ - void afterFindBy(By by, WebElement element, WebDriver driver); -} diff --git a/src/main/java/io/appium/java_client/events/api/general/WindowEventListener.java b/src/main/java/io/appium/java_client/events/api/general/WindowEventListener.java deleted file mode 100644 index 5a50294ec..000000000 --- a/src/main/java/io/appium/java_client/events/api/general/WindowEventListener.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.general; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.Dimension; -import org.openqa.selenium.Point; -import org.openqa.selenium.WebDriver; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface WindowEventListener extends Listener { - /** - * This action will be performed each time before {@link WebDriver.Window#setSize(Dimension)}. - * - * @param driver WebDriver - * @param window is the window whose size is going to be changed - * @param targetSize is the new size - */ - void beforeWindowChangeSize(WebDriver driver, WebDriver.Window window, - Dimension targetSize); - - /** - * This action will be performed each time after {@link WebDriver.Window#setSize(Dimension)}. - * - * @param driver WebDriver - * @param window is the window whose size has been changed - * @param targetSize is the new size - */ - void afterWindowChangeSize(WebDriver driver, WebDriver.Window window, - Dimension targetSize); - - /** - * This action will be performed each time before {@link WebDriver.Window#setPosition(Point)}. - * - * @param driver WebDriver - * @param window is the window whose position is going to be changed - * @param targetPoint is the new window coordinates - */ - void beforeWindowIsMoved(WebDriver driver, WebDriver.Window window, - Point targetPoint); - - /** - * This action will be performed each time after {@link WebDriver.Window#setPosition(Point)}. - * - * @param driver WebDriver - * @param window is the window whose position has been changed - * @param targetPoint is the new window coordinates - */ - void afterWindowIsMoved(WebDriver driver, WebDriver.Window window, - Point targetPoint); - - - /** - * This action will be performed each time before {@link WebDriver.Window#maximize()}. - * - * @param driver WebDriver - * @param window is the window which is going to be maximized - */ - void beforeWindowIsMaximized(WebDriver driver, WebDriver.Window window); - - /** - * This action will be performed each time after {@link WebDriver.Window#maximize()}. - * - * @param driver WebDriver - * @param window is the window which has been maximized - */ - void afterWindowIsMaximized(WebDriver driver, WebDriver.Window window); - - /** - * This action will be performed each time before - * {@link org.openqa.selenium.WebDriver.TargetLocator#window(java.lang.String)}. - * - * @param windowName the name of the window to switch - * @param driver WebDriver - */ - void beforeSwitchToWindow(String windowName, WebDriver driver); - - /** - * This action will be performed each time after - * {@link org.openqa.selenium.WebDriver.TargetLocator#window(java.lang.String)}. - * - * @param windowName the name of the window to switch - * @param driver WebDriver - */ - void afterSwitchToWindow(String windowName, WebDriver driver); -} diff --git a/src/main/java/io/appium/java_client/events/api/mobile/ContextEventListener.java b/src/main/java/io/appium/java_client/events/api/mobile/ContextEventListener.java deleted file mode 100644 index 3372e1b2e..000000000 --- a/src/main/java/io/appium/java_client/events/api/mobile/ContextEventListener.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.mobile; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.WebDriver; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface ContextEventListener extends Listener { - - /** - * Called before {@link org.openqa.selenium.ContextAware#context(String)}. - * - * @param driver Webdriver - * @param context The context that is needed to switch to. - */ - void beforeSwitchingToContext(WebDriver driver, String context); - - /** - * Called after {@link org.openqa.selenium.ContextAware#context(String)}. - * - * @param driver Webdriver - * @param context The context that is needed to switch to. - */ - void afterSwitchingToContext(WebDriver driver, String context); -} diff --git a/src/main/java/io/appium/java_client/events/api/mobile/RotationEventListener.java b/src/main/java/io/appium/java_client/events/api/mobile/RotationEventListener.java deleted file mode 100644 index b57b8542e..000000000 --- a/src/main/java/io/appium/java_client/events/api/mobile/RotationEventListener.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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 io.appium.java_client.events.api.mobile; - -import io.appium.java_client.events.api.Listener; -import org.openqa.selenium.ScreenOrientation; -import org.openqa.selenium.WebDriver; - -/** - * Deprecated. Use EventFiringDecorator and WebDriverListener instead. - */ -@Deprecated -public interface RotationEventListener extends Listener { - - /** - * Called before {@link org.openqa.selenium.Rotatable#rotate(ScreenOrientation)}. - * - * @param driver WebDriver - * @param orientation the desired screen orientation - */ - void beforeRotation(WebDriver driver, ScreenOrientation orientation); - - /** - * Called after {@link org.openqa.selenium.Rotatable#rotate(ScreenOrientation)}. - * - * @param driver WebDriver - * @param orientation the desired screen orientation - */ - void afterRotation(WebDriver driver, ScreenOrientation orientation); -}