Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 753
The addition to #738#741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
The addition to #738 #741
Changes from all commits
a6df515a971cc87307777938ec642419dcaFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -62,20 +62,20 @@ public class AppiumFieldDecorator implements FieldDecorator { | ||
| private static final List<Class<? extends WebElement>> availableElementClasses = ImmutableList.of(WebElement.class, | ||
| RemoteWebElement.class, MobileElement.class, AndroidElement.class, | ||
| IOSElement.class, WindowsElement.class); | ||
| public static long DEFAULT_IMPLICITLY_WAIT_TIMEOUT = 1; | ||
| public static long DEFAULT_TIMEOUT = 1; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can deprecate the constant of TimeUnit type if we use Duration type for DEFAULT_TIMEOUT | ||
| public static TimeUnit DEFAULT_TIMEUNIT = TimeUnit.SECONDS; | ||
| private final WebDriver originalDriver; | ||
| private final DefaultFieldDecorator defaultElementFieldDecoracor; | ||
| private final AppiumElementLocatorFactory widgetLocatorFactory; | ||
| private final String platform; | ||
| private final String automation; | ||
| private final TimeOutDuration timeOutDuration; | ||
| private final TimeOutDuration duration; | ||
| private final HasSessionDetails hasSessionDetails; | ||
| public AppiumFieldDecorator(SearchContext context, long implicitlyWaitTimeOut, | ||
| public AppiumFieldDecorator(SearchContext context, long timeout, | ||
| TimeUnit timeUnit) { | ||
| this(context, new TimeOutDuration(implicitlyWaitTimeOut, timeUnit)); | ||
| this(context, new TimeOutDuration(timeout, timeUnit)); | ||
| } | ||
| /** | ||
| @@ -84,9 +84,9 @@ public AppiumFieldDecorator(SearchContext context, long implicitlyWaitTimeOut, | ||
| * or {@link org.openqa.selenium.WebElement} or | ||
| * {@link io.appium.java_client.pagefactory.Widget} or some other user's | ||
| * extension/implementation. | ||
| * @param timeOutDuration is a desired duration of the waiting for an element presence. | ||
| * @param duration is a desired duration of the waiting for an element presence. | ||
| */ | ||
| public AppiumFieldDecorator(SearchContext context, TimeOutDuration timeOutDuration) { | ||
| public AppiumFieldDecorator(SearchContext context, TimeOutDuration duration) { | ||
| this.originalDriver = unpackWebDriverFromSearchContext(context); | ||
| if (originalDriver == null | ||
| || !HasSessionDetails.class.isAssignableFrom(originalDriver.getClass())) { | ||
| @@ -99,10 +99,10 @@ public AppiumFieldDecorator(SearchContext context, TimeOutDuration timeOutDurati | ||
| automation = hasSessionDetails.getAutomationName(); | ||
| } | ||
| this.timeOutDuration = timeOutDuration; | ||
| this.duration = duration; | ||
| defaultElementFieldDecoracor = new DefaultFieldDecorator( | ||
| new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, | ||
| new AppiumElementLocatorFactory(context, duration, | ||
| new DefaultElementByBuilder(platform, automation))) { | ||
| @Override | ||
| protected WebElement proxyForLocator(ClassLoader ignored, ElementLocator locator) { | ||
| @@ -139,12 +139,11 @@ protected List<WebElement> proxyForListLocator(ClassLoader ignored, | ||
| }; | ||
| widgetLocatorFactory = | ||
| new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, | ||
| new WidgetByBuilder(platform, automation)); | ||
| new AppiumElementLocatorFactory(context, duration, new WidgetByBuilder(platform, automation)); | ||
| } | ||
| public AppiumFieldDecorator(SearchContext context) { | ||
| this(context, DEFAULT_IMPLICITLY_WAIT_TIMEOUT, DEFAULT_TIMEUNIT); | ||
| this(context, DEFAULT_TIMEOUT, DEFAULT_TIMEUNIT); | ||
| } | ||
| /** | ||
| @@ -204,14 +203,14 @@ private Object decorateWidget(Field field) { | ||
| if (isAlist) { | ||
| return getEnhancedProxy(ArrayList.class, | ||
| new WidgetListInterceptor(locator, originalDriver, map, widgetType, | ||
| timeOutDuration)); | ||
| duration)); | ||
| } | ||
| Constructor<? extends Widget> constructor = | ||
| WidgetConstructorUtil.findConvenientConstructor(widgetType); | ||
| return getEnhancedProxy(widgetType, new Class[] {constructor.getParameterTypes()[0]}, | ||
| new Object[] {proxyForAnElement(locator)}, | ||
| new WidgetInterceptor(locator, originalDriver, null, map, timeOutDuration)); | ||
| new WidgetInterceptor(locator, originalDriver, null, map, duration)); | ||
| } | ||
| private WebElement proxyForAnElement(ElementLocator locator) { | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package io.appium.java_client; | ||
| import static java.nio.file.FileSystems.getDefault; | ||
| import static org.openqa.selenium.Platform.MAC; | ||
| import static org.openqa.selenium.Platform.WINDOWS; | ||
| import static org.openqa.selenium.Platform.getCurrent; | ||
| import org.openqa.selenium.Platform; | ||
| import java.io.File; | ||
| import java.nio.file.Path; | ||
| public final class ChromeDriverPathUtil { | ||
| private static final Path ROOT_TEST_PATH = getDefault().getPath("src") | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ | ||
| .resolve("test").resolve("java").resolve("io").resolve("appium").resolve("java_client"); | ||
| /** | ||
| * @return the choromedriver file which depends on platform. | ||
| */ | ||
| public static File getChromeDriver() { | ||
| Platform current = getCurrent(); | ||
| if (current.is(WINDOWS)) { | ||
| return ROOT_TEST_PATH.resolve("chromedriver.exe").toFile(); | ||
| } else if (current.is(MAC)) { | ||
| return ROOT_TEST_PATH.resolve("chromedriver_mac").toFile(); | ||
| } | ||
| return ROOT_TEST_PATH.resolve("chromedriver_linux").toFile(); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method can be marked as Nullable