Skip to content
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

add support to set UiAutomator Congfigurator values #410

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion src/main/java/io/appium/java_client/AppiumSetting.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
*/
public enum AppiumSetting {

IGNORE_UNIMPORTANT_VIEWS("ignoreUnimportantViews");
IGNORE_UNIMPORTANT_VIEWS("ignoreUnimportantViews"),
CONFIGURATOR("configurator");
private String name;

private AppiumSetting(String name) {
Expand Down
60 changes: 59 additions & 1 deletion src/main/java/io/appium/java_client/android/AndroidDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.AppiumSetting;
import io.appium.java_client.FindsByAndroidUIAutomator;
import io.appium.java_client.SwipeElementDirection;
import io.appium.java_client.android.internal.JsonToAndroidElementConverter;
import io.appium.java_client.remote.MobilePlatform;
import io.appium.java_client.service.local.AppiumDriverLocalService;
Expand Down Expand Up @@ -395,6 +394,65 @@ public void ignoreUnimportantViews(Boolean compress) {
setSetting(AppiumSetting.IGNORE_UNIMPORTANT_VIEWS, compress);
}

/**
* Set the `configurator` setting. *Android-only method*.
* Sets the timeouts and delays in {@code com.android.uiautomator.core.Configurator}
*
* @param method set method names in {@code com.android.uiautomator.core.Configurator}
* @param value set method argument, in milliseconds, 0 would reset to their default values
*/
private void configuratorSet(String method, int value) {
setSetting(AppiumSetting.CONFIGURATOR,
String.format("{\"method\":\"%s\",\"value\":%d}", method, value));
}

/**
* invoke {@code setWaitForIdleTimeout} in {@code com.android.uiautomator.core.Configurator}
*
* @param timeout in milliseconds, 0 would reset to its default value
*/
public void configuratorSetWaitForIdleTimeout(int timeout) {
configuratorSet("setWaitForIdleTimeout", timeout);
}

/**
* invoke {@code setWaitForSelectorTimeout} in {@code com.android.uiautomator.core.Configurator}
*
* @param timeout in milliseconds, 0 would reset to its default value
*/
public void configuratorSetWaitForSelectorTimeout(int timeout) {
configuratorSet("setWaitForSelectorTimeout", timeout);
}

/**
* invoke {@code setScrollAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator}
*
* @param timeout in milliseconds, 0 would reset to its default value
*/
public void configuratorSetScrollAcknowledgmentTimeout(int timeout) {
configuratorSet("setScrollAcknowledgmentTimeout", timeout);
}

/**
* invoke {@code configuratorSetKeyInjectionDelay} in {@code com.android.uiautomator.core.Configurator}
*
* @param delay in milliseconds, 0 would reset to its default value
*/
public void configuratorSetKeyInjectionDelay(int delay) {
configuratorSet("setKeyInjectionDelay", delay);
}

/**
* invoke {@code setActionAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator}
*
* @param timeout in milliseconds, 0 would reset to its default value
*/
public void configuratorSetActionAcknowledgmentTimeout(int timeout) {
configuratorSet("setActionAcknowledgmentTimeout", timeout);
}



/**
* @throws org.openqa.selenium.WebDriverException This method is not
* applicable with browser/webview UI.
Expand Down