Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ public List<WebElement> findElements() {
return shouldCache;
}

@Override public String toString() {
return String.format("Located by %s", by);
}


// This function waits for not empty element list using all defined by
private static class WaitingFunction<T> implements Function<Supplier<T>, T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.appium.java_client.pagefactory;

import static io.appium.java_client.pagefactory.ThrowableUtil.extractReadableException;

import io.appium.java_client.pagefactory.interceptors.InterceptorOfASingleElement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand All @@ -37,7 +39,7 @@ class ElementInterceptor extends InterceptorOfASingleElement {
try {
return method.invoke(element, args);
} catch (Throwable t) {
throw ThrowableUtil.extractReadableException(t);
throw extractReadableException(t);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.appium.java_client.pagefactory;

import static io.appium.java_client.pagefactory.ThrowableUtil.extractReadableException;

import io.appium.java_client.pagefactory.interceptors.InterceptorOfAListOfElements;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.pagefactory.ElementLocator;
Expand All @@ -37,7 +39,7 @@ class ElementListInterceptor extends InterceptorOfAListOfElements {
try {
return method.invoke(elements, args);
} catch (Throwable t) {
throw ThrowableUtil.extractReadableException(t);
throw extractReadableException(t);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.appium.java_client.pagefactory;

import static io.appium.java_client.pagefactory.ThrowableUtil.extractReadableException;
import static io.appium.java_client.pagefactory.utils.WebDriverUnpackUtility.getCurrentContentType;

import io.appium.java_client.pagefactory.bys.ContentType;
Expand Down Expand Up @@ -76,7 +77,7 @@ class WidgetInterceptor extends InterceptorOfASingleElement {
method.setAccessible(true);
return method.invoke(cachedInstances.get(type), args);
} catch (Throwable t) {
throw ThrowableUtil.extractReadableException(t);
throw extractReadableException(t);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.appium.java_client.pagefactory;

import static io.appium.java_client.pagefactory.ThrowableUtil.extractReadableException;
import static io.appium.java_client.pagefactory.utils.WebDriverUnpackUtility.getCurrentContentType;

import io.appium.java_client.pagefactory.bys.ContentType;
Expand Down Expand Up @@ -70,7 +71,7 @@ class WidgetListInterceptor extends InterceptorOfAListOfElements {
try {
return method.invoke(cachedWidgets, args);
} catch (Throwable t) {
throw ThrowableUtil.extractReadableException(t);
throw extractReadableException(t);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.openqa.selenium.internal.WrapsDriver;
import org.openqa.selenium.support.pagefactory.ElementLocator;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;


Expand All @@ -37,14 +36,19 @@ public InterceptorOfASingleElement(ElementLocator locator, WebDriver driver) {
}

protected abstract Object getObject(WebElement element, Method method, Object[] args)
throws InvocationTargetException, IllegalAccessException, InstantiationException, Throwable;
throws Throwable;

/**
* Look at
* {@link net.sf.cglib.proxy.MethodInterceptor#intercept(Object, Method, Object[], MethodProxy)}
*/
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
throws Throwable {

if (method.getName().equals("toString") && args.length == 0) {
return locator.toString();
}

if (Object.class.equals(method.getDeclaringClass())) {
return proxy.invokeSuper(obj, args);
}
Expand Down