Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package io.appium.java_client.android;
  
  
 
 import  org.openqa.selenium.Capabilities;
 import  org.openqa.selenium.WebElement;
 import  org.openqa.selenium.remote.Response;
 
 import java.net.URL;
 import java.util.List;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static io.appium.java_client.MobileCommand.*;
 import static io.appium.java_client.remote.MobileCapabilityType.*;

Parameters:
<RequiredElementType> means the required type from the list of allowed types below that implement WebElement Instances of the defined type will be returned via findElement* and findElements*. Warning (!!!). Allowed types:
WebElement
TouchableElement
RemoteWebElement
MobileElement AndroidElement
 
 public class AndroidDriver<RequiredElementType extends WebElement> extends AppiumDriver<RequiredElementType> implements
 		StartsActivityFindsByAndroidUIAutomator<RequiredElementType> {
 
 	private static final String ANDROID_PLATFORM = .;
 
 	private final String METASTATE_PARAM = "metastate";
 	private final String CONNECTION_NAME_PARAM = "name";
 	private final String CONNECTION_PARAM_PARAM = "parameters";
 	private final String DATA_PARAM = "data";
 	private final String INTENT_PARAM = "intent";
 
 	private final String CONNECTION_NAME_VALUE = "network_connection";
 
 	public AndroidDriver(URL remoteAddress, Capabilities desiredCapabilities) {
 		super(remoteAddresssubstituteMobilePlatform(desiredCapabilities,
 	}

  
Scroll forward to the element which has a description or name which contains the input text. The scrolling is performed on the first scrollView present on the UI

Parameters:
text
 
   @Override
   public RequiredElementType scrollTo(String text) {
     String uiScrollables = UiScrollable("new UiSelector().descriptionContains(\"" + text + "\")") +
                            UiScrollable("new UiSelector().textContains(\"" + text + "\")");
     return findElementByAndroidUIAutomator(uiScrollables);
   }

  
Scroll forward to the element which has a description or name which exactly matches the input text. The scrolling is performed on the first scrollView present on the UI

Parameters:
text
 
   @Override
   public RequiredElementType scrollToExact(String text) {
     String uiScrollables = UiScrollable("new UiSelector().description(\"" + text + "\")") +
                            UiScrollable("new UiSelector().text(\"" + text + "\")");
     return findElementByAndroidUIAutomator(uiScrollables);
   }
 
   static String UiScrollable(String uiSelector) {
     return "new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(" + uiSelector + ".instance(0));";
   }

Send a key event to the device

Parameters:
key code for the key pressed on the device
 
 	public void sendKeyEvent(int key) {
 	}

  

Parameters:
key code for the key pressed on the Android device
metastate metastate for the keypress
See also:
AndroidKeyCode
AndroidKeyMetastate
AndroidDeviceActionShortcuts.sendKeyEvent(int, Integer)
	public void sendKeyEvent(int keyInteger metastate) {
		String[] parameters = new String[] {  };
		Object[] values = new Object[] { keymetastate };
		execute(getCommandImmutableMap(parametersvalues));
	}

See also:
HasNetworkConnection.getNetworkConnection()
		Response response = execute();
		return new NetworkConnectionSetting(Integer.parseInt(response
				.getValue().toString()));
	}

Parameters:
connection The NetworkConnectionSetting configuration to use for the device
See also:
HasNetworkConnection.setNetworkConnection(NetworkConnectionSetting)
	public void setNetworkConnection(NetworkConnectionSetting connection) {
		// the new version of the webdriver protocol is going forward with
		// sending JSON message which look like
		// {name: "name of endpoint", parameters: "JSON parameters"}
		// this is for webdrivers which run on protocols besides HTTP (like TCP)
		// we're implementing that pattern here, for this new method, but
		// haven't translated it to all other commands yet
		String[] parameters = new String[] { ,
		Object[] values = new Object[] { ,
				ImmutableMap.of("type"connection.value) };
				getCommandImmutableMap(parametersvalues));
	}

Parameters:
remotePath Path to file to write data to on remote device
base64Data Base64 encoded byte array of data to write to remote device
See also:
PushesFiles.pushFile(String, byte[])
	public void pushFile(String remotePathbyte[] base64Data) {
		String[] parameters = new String[] {  };
		Object[] values = new Object[] { remotePathbase64Data };
		execute(getCommandImmutableMap(parametersvalues));
	}

Parameters:
appPackage The package containing the activity. [Required]
appActivity The activity to start. [Required]
appWaitPackage Automation will begin after this package starts. [Optional]
appWaitActivity Automation will begin after this activity starts. [Optional]
See also:
StartsActivity.startActivity(String, String, String, String)
Example:
driver.startActivity("com.foo.bar", ".MyActivity", null, null);
	public void startActivity(String appPackageString appActivity,
			String appWaitPackageString appWaitActivity)
				(_isNotNullOrEmpty(appPackage) && _isNotNullOrEmpty(appActivity)),
				String.format("'%s' and '%s' are required.",
		appWaitPackage = _isNotNullOrEmpty(appWaitPackage) ? appWaitPackage
"";
		appWaitActivity = _isNotNullOrEmpty(appWaitActivity) ? appWaitActivity
"";
		ImmutableMap<StringStringparameters = ImmutableMap.of(,
				appPackageappActivity,
				appWaitPackageappWaitActivity);
		execute(parameters);
	}

Parameters:
appPackage The package containing the activity. [Required]
appActivity The activity to start. [Required]
See also:
StartsActivity.startActivity(String, String)
Example:
*.startActivity("com.foo.bar", ".MyActivity");
	public void startActivity(String appPackageString appActivity)
		this.startActivity(appPackageappActivitynullnull);		
	}

Get test-coverage data

Parameters:
intent intent to broadcast
path path to .ec file
	public void endTestCoverage(String intentString path) {	
		String[] parameters = new String[] {  };
		Object[] values = new Object[] { intentpath };
	}

Get the current activity being run on the mobile device
	public String currentActivity() {
		Response response = execute();
		return response.getValue().toString();
	}	

Open the notification shade, on Android devices.
	public void openNotifications() {
	}	

Check if the device is locked.

Returns:
true if device is locked. False otherwise
	public boolean isLocked() {
		Response response = execute();
		return Boolean.parseBoolean(response.getValue().toString());
	}
	public void toggleLocationServices() {
	}

Set the `ignoreUnimportantViews` setting. *Android-only method* Sets whether Android devices should use `setCompressedLayoutHeirarchy()` which ignores all views which are marked IMPORTANT_FOR_ACCESSIBILITY_NO or IMPORTANT_FOR_ACCESSIBILITY_AUTO (and have been deemed not important by the system), in an attempt to make things less confusing or faster.

Parameters:
compress ignores unimportant views if true, doesn't ignore otherwise.
	// Should be moved to the subclass
	public void ignoreUnimportantViews(Boolean compress) {
	}	
	@SuppressWarnings("unchecked")
	public RequiredElementType findElementByAndroidUIAutomator(String using) {
		return (RequiredElementType) findElement("-android uiautomator"using);
	}
	@SuppressWarnings("unchecked")
	public List<RequiredElementType> findElementsByAndroidUIAutomator(String using) {
		return (List<RequiredElementType>) findElements("-android uiautomator"using);
	}	
New to GrepCode? Check out our FAQ X