How to use HasAppStrings class of io.appium.java_client package

Best io.appium code snippet using io.appium.java_client.HasAppStrings

AppiumDriver_4.1.2.java

Source:AppiumDriver_4.1.2.java Github

copy

Full Screen

...511        locationContext.setLocation(location);512    }513    /**514     * @return a map with localized strings defined in the app.515     * @see HasAppStrings#getAppStringMap().516     */517    @Override public Map<String, String> getAppStringMap() {518        Response response = execute(GET_STRINGS);519        return (Map<String, String>) response.getValue();520    }521    /**522     * @param language strings language code.523     * @return a map with localized strings defined in the app.524     * @see HasAppStrings#getAppStringMap(String).525     */526    @Override public Map<String, String> getAppStringMap(String language) {527        Response response = execute(GET_STRINGS, prepareArguments("language", language));528        return (Map<String, String>) response.getValue();529    }530    /**531     * @param language   strings language code.532     * @param stringFile strings filename.533     * @return a map with localized strings defined in the app.534     * @see HasAppStrings#getAppStringMap(String, String).535     */536    @Override public Map<String, String> getAppStringMap(String language, String stringFile) {537        String[] parameters = new String[] {"language", "stringFile"};538        Object[] values = new Object[] {language, stringFile};539        Response response = execute(GET_STRINGS, prepareArguments(parameters, values));540        return (Map<String, String>) response.getValue();541    }542    private TouchAction createTap(WebElement element, int duration) {543        TouchAction tap = new TouchAction(this);544        return tap.press(element).waitAction(duration).release();545    }546    private TouchAction createTap(int x, int y, int duration) {547        TouchAction tap = new TouchAction(this);548        return tap.press(x, y).waitAction(duration).release();...

Full Screen

Full Screen

WebDriverWrapper.java

Source:WebDriverWrapper.java Github

copy

Full Screen

...30import io.appium.java_client.FindsByAndroidUIAutomator;31import io.appium.java_client.FindsByFluentSelector;32import io.appium.java_client.FindsByIosUIAutomation;33import io.appium.java_client.FindsByWindowsAutomation;34import io.appium.java_client.HasAppStrings;35import io.appium.java_client.HasDeviceTime;36import io.appium.java_client.HasSessionDetails;37import io.appium.java_client.HidesKeyboard;38import io.appium.java_client.HidesKeyboardWithKeyName;39import io.appium.java_client.InteractsWithApps;40import io.appium.java_client.InteractsWithFiles;41import io.appium.java_client.MobileDriver;42import io.appium.java_client.MultiTouchAction;43import io.appium.java_client.PerformsActions;44import io.appium.java_client.PerformsTouchActions;45import io.appium.java_client.PressesKeyCode;46import io.appium.java_client.TouchAction;47import io.appium.java_client.android.AndroidDriver;48import io.appium.java_client.android.Connection;49import io.appium.java_client.android.HasNetworkConnection;50import io.appium.java_client.android.PushesFiles;51import io.appium.java_client.android.StartsActivity;52import io.appium.java_client.ios.ShakesDevice;53import io.appium.java_client.windows.WindowsKeyCode;54/**55 * This class is a "simple" extension of Selenium's EventFiringWebDriver that56 * additionally implements several useful interfaces.57 * 58 * @author Sachin Kumar 12 [skumar213@sapient.com]59 */60public class WebDriverWrapper extends EventFiringWebDriver implements FindsById, FindsByClassName, FindsByLinkText,61		FindsByName, FindsByCssSelector, FindsByTagName, FindsByXPath, HasCapabilities, MobileDriver, Rotatable,62		LocationContext, ContextAware, InteractsWithApps, HasAppStrings, HasNetworkConnection, PushesFiles,63		StartsActivity, FindsByAndroidUIAutomator, HasDeviceTime, HidesKeyboard, HidesKeyboardWithKeyName,64		PressesKeyCode, ShakesDevice, HasSessionDetails, FindsByIosUIAutomation, HasIdentity, PerformsTouchActions,65		FindsByFluentSelector, FindsByAccessibilityId, PerformsActions, FindsByWindowsAutomation, WindowsKeyCode {66	/**67	 * Constructs WebDriverWrapper.68	 *69	 * @param driver70	 *            instance of WebDriver.71	 * @param frameSwitcher72	 *            instance of FrameSwitcher.73	 */74	public WebDriverWrapper(WebDriver driver) {75		super(driver);76	}77	/**78	 * @return The capabilities of the current driver.79	 */80	@Override81	public Capabilities getCapabilities() {82		return ((HasCapabilities) super.getWrappedDriver()).getCapabilities();83	}84	/**85	 * Finds element by xpath.86	 */87	@Override88	public WebElement findElementByXPath(String xPath) {89		return ((FindsByXPath) super.getWrappedDriver()).findElementByXPath(xPath);90	}91	/**92	 * Finds elements by xpath.93	 */94	@Override95	public List<WebElement> findElementsByXPath(String xPath) {96		return ((FindsByXPath) super.getWrappedDriver()).findElementsByXPath(xPath);97	}98	/**99	 * Finds element by tag name.100	 */101	@Override102	public WebElement findElementByTagName(String tagName) {103		return ((FindsByTagName) super.getWrappedDriver()).findElementByTagName(tagName);104	}105	/**106	 * Finds elements by tag name.107	 */108	@Override109	public List<WebElement> findElementsByTagName(String tagName) {110		return ((FindsByTagName) super.getWrappedDriver()).findElementsByTagName(tagName);111	}112	/**113	 * Finds element by css selector.114	 */115	@Override116	public WebElement findElementByCssSelector(String cssSelector) {117		return ((FindsByCssSelector) super.getWrappedDriver()).findElementByCssSelector(cssSelector);118	}119	/**120	 * Finds elements by css selector.121	 */122	@Override123	public List<WebElement> findElementsByCssSelector(String cssSelector) {124		return ((FindsByCssSelector) super.getWrappedDriver()).findElementsByCssSelector(cssSelector);125	}126	/**127	 * Finds element by name.128	 */129	@Override130	public WebElement findElementByName(String name) {131		return ((FindsByName) super.getWrappedDriver()).findElementByName(name);132	}133	/**134	 * Finds elements by name.135	 */136	@Override137	public List<WebElement> findElementsByName(String name) {138		return ((FindsByName) super.getWrappedDriver()).findElementsByName(name);139	}140	/**141	 * Finds element by link text.142	 */143	@Override144	public WebElement findElementByLinkText(String linkText) {145		return ((FindsByLinkText) super.getWrappedDriver()).findElementByLinkText(linkText);146	}147	/**148	 * Finds elements by link text.149	 */150	@Override151	public List<WebElement> findElementsByLinkText(String linkText) {152		return ((FindsByLinkText) super.getWrappedDriver()).findElementsByLinkText(linkText);153	}154	/**155	 * Finds element by partial link text.156	 */157	@Override158	public WebElement findElementByPartialLinkText(String partialLinkText) {159		return ((FindsByLinkText) super.getWrappedDriver()).findElementByPartialLinkText(partialLinkText);160	}161	/**162	 * Finds elements by partial link text.163	 */164	@Override165	public List<WebElement> findElementsByPartialLinkText(String partialLinkText) {166		return ((FindsByLinkText) super.getWrappedDriver()).findElementsByPartialLinkText(partialLinkText);167	}168	/**169	 * Finds element by class name.170	 */171	@Override172	public WebElement findElementByClassName(String className) {173		return ((FindsByClassName) super.getWrappedDriver()).findElementByClassName(className);174	}175	/**176	 * Finds elements by class name.177	 */178	@Override179	public List<WebElement> findElementsByClassName(String className) {180		return ((FindsByClassName) super.getWrappedDriver()).findElementsByClassName(className);181	}182	/**183	 * Finds element by id.184	 */185	@Override186	public WebElement findElementById(String id) {187		return ((FindsById) super.getWrappedDriver()).findElementById(id);188	}189	/**190	 * Finds elements by id.191	 */192	@Override193	public List<WebElement> findElementsById(String id) {194		return ((FindsById) super.getWrappedDriver()).findElementsById(id);195	}196	@Override197	public TouchAction performTouchAction(TouchAction touchAction) {198		return ((PerformsTouchActions) super.getWrappedDriver()).performTouchAction(touchAction);199	}200	@Override201	public void performMultiTouchAction(MultiTouchAction multiAction) {202		((PerformsTouchActions) super.getWrappedDriver()).performMultiTouchAction(multiAction);203	}204	@Override205	public void launchApp() {206		((InteractsWithApps) super.getWrappedDriver()).launchApp();207	}208	@Override209	public void installApp(String appPath) {210		((InteractsWithApps) super.getWrappedDriver()).installApp(appPath);211	}212	@Override213	public boolean isAppInstalled(String bundleId) {214		return ((InteractsWithApps) super.getWrappedDriver()).isAppInstalled(bundleId);215	}216	@Override217	public void resetApp() {218		((InteractsWithApps) super.getWrappedDriver()).resetApp();219	}220	@Override221	public void runAppInBackground(int seconds) {222		((InteractsWithApps) super.getWrappedDriver()).runAppInBackground(seconds);223	}224	@Override225	public void removeApp(String bundleId) {226		((InteractsWithApps) super.getWrappedDriver()).removeApp(bundleId);227	}228	@Override229	public void closeApp() {230		((InteractsWithApps) super.getWrappedDriver()).closeApp();231	}232	@Override233	public byte[] pullFile(String remotePath) {234		return ((InteractsWithFiles) super.getWrappedDriver()).pullFile(remotePath);235	}236	@Override237	public byte[] pullFolder(String remotePath) {238		return ((InteractsWithFiles) super.getWrappedDriver()).pullFolder(remotePath);239	}240	@Override241	public Location location() {242		return ((LocationContext) super.getWrappedDriver()).location();243	}244	@Override245	public void setLocation(Location arg0) {246		((LocationContext) super.getWrappedDriver()).setLocation(arg0);247	}248	@Override249	public WebElement findElementByAccessibilityId(String using) {250		return ((FindsByAccessibilityId) super.getWrappedDriver()).findElementByAccessibilityId(using);251	}252	@Override253	public List<WebElement> findElementsByAccessibilityId(String using) {254		return ((FindsByAccessibilityId) super.getWrappedDriver()).findElementsByAccessibilityId(using);255	}256	@Override257	public ScreenOrientation getOrientation() {258		return ((Rotatable) super.getWrappedDriver()).getOrientation();259	}260	@Override261	public void rotate(DeviceRotation deviceRotation) {262		((Rotatable) super.getWrappedDriver()).rotate(deviceRotation);263	}264	@Override265	public DeviceRotation rotation() {266		return ((Rotatable) super.getWrappedDriver()).rotation();267	}268	@Override269	public void rotate(ScreenOrientation screenOrientation) {270		((Rotatable) super.getWrappedDriver()).rotate(screenOrientation);271	}272	@Override273	public WebDriver context(String name) {274		return ((ContextAware) super.getWrappedDriver()).context(name);275	}276	@Override277	public String getContext() {278		return ((ContextAware) super.getWrappedDriver()).getContext();279	}280	@Override281	public Set<String> getContextHandles() {282		return ((ContextAware) super.getWrappedDriver()).getContextHandles();283	}284	@Override285	public Response execute(String driverCommand, Map parameters) {286		return ((MobileDriver) super.getWrappedDriver()).execute(driverCommand, parameters);287	}288	@Override289	public WebElement findElementByIosUIAutomation(String using) {290		return ((FindsByIosUIAutomation) super.getWrappedDriver()).findElementByIosUIAutomation(using);291	}292	@Override293	public List<WebElement> findElementsByIosUIAutomation(String using) {294		return ((FindsByIosUIAutomation) super.getWrappedDriver()).findElementsByIosUIAutomation(using);295	}296	@Override297	public WebElement findElementByAndroidUIAutomator(String using) {298		return ((FindsByAndroidUIAutomator) super.getWrappedDriver()).findElementByAndroidUIAutomator(using);299	}300	@Override301	public List<WebElement> findElementsByAndroidUIAutomator(String using) {302		return ((FindsByAndroidUIAutomator) super.getWrappedDriver()).findElementsByAndroidUIAutomator(using);303	}304	@Override305	public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity,306			boolean stopApp) throws IllegalArgumentException {307		((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity, appWaitPackage,308				appWaitActivity, stopApp);309	}310	@Override311	public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity) {312		((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity, appWaitPackage,313				appWaitActivity);314	}315	@Override316	public void startActivity(String appPackage, String appActivity) {317		((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity);318	}319	@Override320	public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity,321			String intentAction, String intentCategory, String intentFlags, String intentOptionalArgs)322			throws IllegalArgumentException {323		((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity, appWaitPackage,324				appWaitActivity, intentAction, intentCategory, intentFlags, intentOptionalArgs);325	}326	@Override327	public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity,328			String intentAction, String intentCategory, String intentFlags, String intentOptionalArgs, boolean stopApp)329			throws IllegalArgumentException {330		((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity, appWaitPackage,331				appWaitActivity, intentAction, intentCategory, intentFlags, intentOptionalArgs, stopApp);332	}333	@Override334	public void pushFile(String remotePath, byte[] base64Data) {335		((PushesFiles) super.getWrappedDriver()).pushFile(remotePath, base64Data);336	}337	@Override338	public void pushFile(String remotePath, File file) throws IOException {339		((PushesFiles) super.getWrappedDriver()).pushFile(remotePath, file);340	}341	@Override342	public TargetLocator switchTo() {343		return super.getWrappedDriver().switchTo();344	}345	@Override346	public Map<String, String> getAppStringMap() {347		return ((HasAppStrings) super.getWrappedDriver()).getAppStringMap();348	}349	@Override350	public Map<String, String> getAppStringMap(String language) {351		return ((HasAppStrings) super.getWrappedDriver()).getAppStringMap(language);352	}353	@Override354	public Map<String, String> getAppStringMap(String language, String stringFile) {355		return ((HasAppStrings) super.getWrappedDriver()).getAppStringMap(language, stringFile);356	}357	@Override358	public void pressKeyCode(int key) {359		((AndroidDriver) super.getWrappedDriver()).longPressKeyCode(key);360	}361	@Override362	public void pressKeyCode(int key, Integer metastate) {363		((AndroidDriver) super.getWrappedDriver()).pressKeyCode(key, metastate);364	}365	@Override366	public void longPressKeyCode(int key) {367		((AndroidDriver) super.getWrappedDriver()).longPressKeyCode(key);368	}369	@Override...

Full Screen

Full Screen

AbstractAppiumPhoenixDriver.java

Source:AbstractAppiumPhoenixDriver.java Github

copy

Full Screen

...15 */16package com.comcast.magicwand.spells.appium;17import io.appium.java_client.AppiumDriver;18import io.appium.java_client.DeviceActionShortcuts;19import io.appium.java_client.HasAppStrings;20import io.appium.java_client.InteractsWithApps;21import io.appium.java_client.InteractsWithFiles;22import io.appium.java_client.MultiTouchAction;23import io.appium.java_client.PerformsTouchActions;24import io.appium.java_client.TouchAction;25import io.appium.java_client.TouchShortcuts;26import java.net.URL;27import java.util.List;28import java.util.Map;29import java.util.Set;30import org.openqa.selenium.ScreenOrientation;31import org.openqa.selenium.WebDriver;32import org.openqa.selenium.WebElement;33import org.openqa.selenium.html5.Location;34import org.openqa.selenium.remote.ExecuteMethod;35import org.openqa.selenium.remote.Response;36import com.comcast.cookie.CookieHandler;37import com.comcast.cookie.handlers.GeneralCookieHandler;38import com.comcast.magicwand.drivers.AbstractPhoenixDriver;39import com.google.gson.JsonObject;40/**41 * Common functionality of Appium Driver42 *43 * @author Dmitry Jerusalimsky44 *45 */46public abstract class AbstractAppiumPhoenixDriver extends AbstractPhoenixDriver {47    protected AppiumDriver driver;48    CookieHandler cookieHandler = new GeneralCookieHandler();49    /**50     * Creates an instance of {@link AbstractAppiumPhoenixDriver}51     *52     * @param driver Underlying {@link AppiumDriver}53     */54    public AbstractAppiumPhoenixDriver(AppiumDriver driver) {55        this.driver = driver;56    }57    /**58     * {@inheritDoc}59     */60    public WebDriver getDriver() {61        return this.driver;62    }63    /**64     * Executes a command65     *66     * @param driverCommand Driver command name to execute67     * @param parameters Parameters used to execute the command68     * @return Response of the execution69     */70    public Response execute(String driverCommand, Map<String, ?> parameters) {71        return this.driver.execute(driverCommand, parameters);72    }73    /**74     * Executes a method75     *76     * @return {@link ExecuteMethod}77     */78    public ExecuteMethod getExecuteMethod() {79        return this.driver.getExecuteMethod();80    }81    /**82     * @see InteractsWithApps#resetApp()83     */84    public void resetApp() {85        this.driver.resetApp();86    }87    /**88     * @see InteractsWithApps#isAppInstalled(String)89     *90     * @param bundleId Bundle ID of an app to check91     * @return True if application is installed or false otherwise92     */93    public boolean isAppInstalled(String bundleId) {94        return this.driver.isAppInstalled(bundleId);95    }96    /**97     * @see InteractsWithApps#installApp(String)98     * @param appPath Path to the application to install99     */100    public void installApp(String appPath) {101        this.driver.installApp(appPath);102    }103    /**104     * @see InteractsWithApps#removeApp(String)105     * @param bundleId Bundle id of an app to remove106     */107    public void removeApp(String bundleId) {108        this.driver.removeApp(bundleId);109    }110    /**111     * @see InteractsWithApps#launchApp()112     */113    public void launchApp() {114        this.driver.launchApp();115    }116    /**117     * @see InteractsWithApps#closeApp()118     */119    public void closeApp() {120        this.driver.closeApp();121    }122    /**123     * @see InteractsWithApps#runAppInBackground(int)124     * @param seconds Number of seconds to run the app for125     */126    public void runAppInBackground(int seconds) {127        this.driver.runAppInBackground(seconds);128    }129    /**130     * @see DeviceActionShortcuts#hideKeyboard()131     */132    public void hideKeyboard() {133        this.driver.hideKeyboard();134    }135    /**136     * @see InteractsWithFiles#pullFile(String)137     * @param remotePath Path to a file to pull138     * @return Byte data representing a pulled file139     */140    public byte[] pullFile(String remotePath) {141        return this.driver.pullFile(remotePath);142    }143    /**144     * @see InteractsWithFiles#pullFolder(String)145     * @param remotePath Path to a folder to pull146     *147     * @return byte data representing a pulled folder148     */149    public byte[] pullFolder(String remotePath) {150        return this.driver.pullFolder(remotePath);151    }152    /**153     * @see PerformsTouchActions#performTouchAction(TouchAction)154     * @param touchAction Action to perform155     * @return Touch action156     */157    public TouchAction performTouchAction(TouchAction touchAction) {158        return this.driver.performTouchAction(touchAction);159    }160    /**161     * @see PerformsTouchActions#performMultiTouchAction(MultiTouchAction)162     * @param multiAction actions to perform163     */164    public void performMultiTouchAction(MultiTouchAction multiAction) {165        this.driver.performMultiTouchAction(multiAction);166    }167    /**168     * @see TouchShortcuts#tap(int, WebElement, int)169     * @param fingers Number of fingers used to perform a tap170     * @param element Element to tap171     * @param duration Duration of a tap172     */173    public void tap(int fingers, WebElement element, int duration) {174        this.driver.tap(fingers, element, duration);175    }176    /**177     * @see TouchShortcuts#tap(int, int, int, int)178     * @param fingers Number of fingers used to perform a tap179     * @param x X coordinate to tap180     * @param y Y coordinate to tap181     * @param duration Duration of a tap182     */183    public void tap(int fingers, int x, int y, int duration) {184        this.driver.tap(fingers, x, y, duration);185    }186    /**187     * @see TouchShortcuts#swipe(int, int, int, int, int)188     * @param startx Starting X position of a swipe189     * @param starty Starting Y position of a swipe190     * @param endx Ending X position of a swipe191     * @param endy Ending Y position of a swipe192     * @param duration Duration of a tap193     */194    public void swipe(int startx, int starty, int endx, int endy, int duration) {195        this.driver.swipe(startx, starty, endx, endy, duration);196    }197    /**198     * Convenience method for pinching an element on the screen. "pinching" refers to the action of two appendages199     * pressing the screen and sliding towards each other. NOTE: This convenience method places the initial touches200     * around the element, if this would happen to place one of them off the screen, appium with return an outOfBounds201     * error. In this case, revert to using the MultiTouchAction api instead of this method.202     *203     * @param el The element to pinch204     */205    public void pinch(WebElement el) {206        this.driver.pinch(el);207    }208    /**209     * Convenience method for pinching an element on the screen. "pinching" refers to the action of two appendages210     * pressing the screen and sliding towards each other. NOTE: This convenience method places the initial touches211     * around the element at a distance, if this would happen to place one of them off the screen, appium will return an212     * outOfBounds error. In this case, revert to using the MultiTouchAction api instead of this method.213     *214     * @param x x coordinate to terminate the pinch on215     * @param y y coordinate to terminate the pinch on216     */217    public void pinch(int x, int y) {218        this.driver.pinch(x, y);219    }220    /**221     * Convenience method for "zooming in" on an element on the screen. "zooming in" refers to the action of two222     * appendages pressing the screen and sliding away from each other. NOTE: This convenience method slides touches223     * away from the element, if this would happen to place one of them off the screen, appium will return an224     * outOfBounds error. In this case, revert to using the MultiTouchAction api instead of this method.225     *226     * @param el The element to pinch227     */228    public void zoom(WebElement el) {229        this.driver.zoom(el);230    }231    /**232     * Convenience method for "zooming in" on an element on the screen. "zooming in" refers to the action of two233     * appendages pressing the screen and sliding away from each other. NOTE: This convenience method slides touches234     * away from the element, if this would happen to place one of them off the screen, appium will return an235     * outOfBounds error. In this case, revert to using the MultiTouchAction api instead of this method.236     *237     * @param x x coordinate to start zoom on238     * @param y y coordinate to start zoom on239     */240    public void zoom(int x, int y) {241        this.driver.zoom(x, y);242    }243    /**244     * Get settings stored for this test session It's probably better to use a convenience function, rather than use245     * this function directly. Try finding the method for the specific setting you want to read246     *247     * @return JsonObject, a straight-up hash of settings248     */249    public JsonObject getSettings() {250        return this.driver.getSettings();251    }252    /**253     * Lock the device (bring it to the lock screen) for a given number of seconds254     *255     * @param seconds number of seconds to lock the screen for256     */257    public void lockScreen(int seconds) {258        this.driver.lockScreen(seconds);259    }260    /**261     * Switches contexts262     *263     * @param name Name of the context to switch to264     * @return Reference of a web driver with a new context265     */266    public WebDriver context(String name) {267        return this.driver.context(name);268    }269    /**270     * Gets names of available contexts271     *272     * @return Names of contexts273     */274    public Set<String> getContextHandles() {275        return this.driver.getContextHandles();276    }277    /**278     * Gets current driver context279     *280     * @return Name of the current context281     */282    public String getContext() {283        return this.driver.getContext();284    }285    /**286     * Rotates device287     *288     * @param orientation Expected final orientation289     */290    public void rotate(ScreenOrientation orientation) {291        this.driver.rotate(orientation);292    }293    /**294     * Gets device orientation295     *296     * @return Screen orientation297     */298    public ScreenOrientation getOrientation() {299        return this.driver.getOrientation();300    }301    /**302     * Searches for element by accessibility id303     *304     * @param using Accessibility ID value to search for305     * @return Element that matched search criteria306     */307    public WebElement findElementByAccessibilityId(String using) {308        return this.driver.findElementByAccessibilityId(using);309    }310    /**311     * Searches for elements by accessibility id312     *313     * @param using Accessibility ID value to search for314     * @return Elements that matched search criteria315     */316    public List<WebElement> findElementsByAccessibilityId(String using) {317        return this.driver.findElementsByAccessibilityId(using);318    }319    /**320     * Gets driver location321     *322     * @return Location323     */324    public Location location() {325        return this.driver.location();326    }327    /**328     * Sets driver location329     *330     * @param location Location to set331     */332    public void setLocation(Location location) {333        this.driver.setLocation(location);334    }335    /**336     * @see HasAppStrings#getAppStrings()337     * @return application strings338     */339    public String getAppStrings() {340        return this.driver.getAppStrings();341    }342    /**343     * @param language strings language code344     * @return a string of all the localized strings defined in the app345     *346     * @see HasAppStrings#getAppStrings(String)347     */348    public String getAppStrings(String language) {349        return this.driver.getAppStrings(language);350    }351    /**352     * Gets driver's remote URL353     *354     * @return URL of the appium server355     */356    public URL getRemoteAddress() {357        return this.driver.getRemoteAddress();358    }359    /**360     * {@inheritDoc}...

Full Screen

Full Screen

AndroidDriver.java

Source:AndroidDriver.java Github

copy

Full Screen

...21import com.google.common.collect.ImmutableMap;22import io.appium.java_client.AppiumDriver;23import io.appium.java_client.CommandExecutionHelper;24import io.appium.java_client.ExecuteCDPCommand;25import io.appium.java_client.HasAppStrings;26import io.appium.java_client.HasDeviceTime;27import io.appium.java_client.HasOnScreenKeyboard;28import io.appium.java_client.HidesKeyboard;29import io.appium.java_client.InteractsWithApps;30import io.appium.java_client.PullsFiles;31import io.appium.java_client.LocksDevice;32import io.appium.java_client.PerformsTouchActions;33import io.appium.java_client.PushesFiles;34import io.appium.java_client.SupportsLegacyAppManagement;35import io.appium.java_client.android.connection.HasNetworkConnection;36import io.appium.java_client.android.geolocation.SupportsExtendedGeolocationCommands;37import io.appium.java_client.android.nativekey.PressesKey;38import io.appium.java_client.battery.HasBattery;39import io.appium.java_client.remote.SupportsContextSwitching;40import io.appium.java_client.remote.SupportsLocation;41import io.appium.java_client.remote.SupportsRotation;42import io.appium.java_client.screenrecording.CanRecordScreen;43import io.appium.java_client.service.local.AppiumDriverLocalService;44import io.appium.java_client.service.local.AppiumServiceBuilder;45import io.appium.java_client.ws.StringWebSocketClient;46import org.openqa.selenium.Capabilities;47import org.openqa.selenium.Platform;48import org.openqa.selenium.remote.HttpCommandExecutor;49import org.openqa.selenium.remote.html5.RemoteLocationContext;50import org.openqa.selenium.remote.http.HttpClient;51import java.net.URL;52import java.util.Collections;53import java.util.Map;54/**55 * Android driver implementation.56 */57public class AndroidDriver extends AppiumDriver implements58        PressesKey,59        SupportsRotation,60        SupportsContextSwitching,61        SupportsLocation,62        PerformsTouchActions,63        HidesKeyboard,64        HasDeviceTime,65        PullsFiles,66        InteractsWithApps,67        SupportsLegacyAppManagement,68        HasAppStrings,69        HasNetworkConnection,70        PushesFiles,71        StartsActivity,72        LocksDevice,73        HasAndroidSettings,74        HasAndroidDeviceDetails,75        HasSupportedPerformanceDataType,76        AuthenticatesByFinger,77        HasOnScreenKeyboard,78        CanRecordScreen,79        SupportsSpecialEmulatorCommands,80        SupportsNetworkStateManagement,81        ListensToLogcatMessages,82        HasAndroidClipboard,...

Full Screen

Full Screen

IOSDriver.java

Source:IOSDriver.java Github

copy

Full Screen

...17import static io.appium.java_client.MobileCommand.prepareArguments;18import static org.openqa.selenium.remote.DriverCommand.EXECUTE_SCRIPT;19import com.google.common.collect.ImmutableMap;20import io.appium.java_client.AppiumDriver;21import io.appium.java_client.HasAppStrings;22import io.appium.java_client.HasDeviceTime;23import io.appium.java_client.HasOnScreenKeyboard;24import io.appium.java_client.HidesKeyboard;25import io.appium.java_client.HidesKeyboardWithKeyName;26import io.appium.java_client.InteractsWithApps;27import io.appium.java_client.PullsFiles;28import io.appium.java_client.LocksDevice;29import io.appium.java_client.PerformsTouchActions;30import io.appium.java_client.PushesFiles;31import io.appium.java_client.SupportsLegacyAppManagement;32import io.appium.java_client.battery.HasBattery;33import io.appium.java_client.remote.SupportsContextSwitching;34import io.appium.java_client.remote.SupportsLocation;35import io.appium.java_client.remote.SupportsRotation;36import io.appium.java_client.screenrecording.CanRecordScreen;37import io.appium.java_client.service.local.AppiumDriverLocalService;38import io.appium.java_client.service.local.AppiumServiceBuilder;39import io.appium.java_client.ws.StringWebSocketClient;40import org.openqa.selenium.Alert;41import org.openqa.selenium.Capabilities;42import org.openqa.selenium.Platform;43import org.openqa.selenium.remote.DriverCommand;44import org.openqa.selenium.remote.HttpCommandExecutor;45import org.openqa.selenium.remote.Response;46import org.openqa.selenium.remote.html5.RemoteLocationContext;47import org.openqa.selenium.remote.http.HttpClient;48import java.net.URL;49import java.util.Collections;50import java.util.Map;51/**52 * iOS driver implementation.53 */54public class IOSDriver extends AppiumDriver implements55        SupportsContextSwitching,56        SupportsRotation,57        SupportsLocation,58        HidesKeyboard,59        HasDeviceTime,60        PullsFiles,61        InteractsWithApps,62        SupportsLegacyAppManagement,63        HasAppStrings,64        PerformsTouchActions,65        HidesKeyboardWithKeyName,66        ShakesDevice,67        HasIOSSettings,68        HasOnScreenKeyboard,69        LocksDevice,70        PerformsTouchID,71        PushesFiles,72        CanRecordScreen,73        HasIOSClipboard,74        ListensToSyslogMessages,75        HasBattery<IOSBatteryInfo> {76    private static final String PLATFORM_NAME = Platform.IOS.name();77    private StringWebSocketClient syslogClient;...

Full Screen

Full Screen

NativeContent.java

Source:NativeContent.java Github

copy

Full Screen

1package com.github.arachnidium.model.mobile;23import io.appium.java_client.AppiumDriver;4import io.appium.java_client.DeviceActionShortcuts;5import io.appium.java_client.HasAppStrings;6import io.appium.java_client.MobileElement;7import io.appium.java_client.ScrollsTo;8import io.appium.java_client.TouchShortcuts;9import io.appium.java_client.android.AndroidDriver;1011import org.openqa.selenium.Rotatable;12import org.openqa.selenium.ScreenOrientation;13import org.openqa.selenium.WebElement;1415import com.github.arachnidium.core.MobileContextNamePatterns;16import com.github.arachnidium.core.MobileScreen;17import com.github.arachnidium.core.components.mobile.NativeTouchActions;18import com.github.arachnidium.model.common.FunctionalPart;19import com.github.arachnidium.model.support.annotations.ExpectedContext;2021/**22 * Can be used to describe a single mobile app native screen or its fragment23 */24@ExpectedContext(regExp = MobileContextNamePatterns.NATIVE)25public abstract class NativeContent extends FunctionalPart<MobileScreen> implements Rotatable, 26DeviceActionShortcuts, TouchShortcuts, ScrollsTo<MobileElement>, HasAppStrings {2728	protected final NativeTouchActions touchActions;29	3031	/**32	 * @see FunctionalPart#FunctionalPart(com.github.arachnidium.core.Handle)33	 */34	protected NativeContent(MobileScreen context) {35		super(context);36		touchActions = getComponent(NativeTouchActions.class);37	}38	3940	/**
...

Full Screen

Full Screen

HasAppStrings.java

Source:HasAppStrings.java Github

copy

Full Screen

...17import static io.appium.java_client.MobileCommand.GET_STRINGS;18import static io.appium.java_client.MobileCommand.prepareArguments;19import java.util.AbstractMap;20import java.util.Map;21public interface HasAppStrings extends ExecutesMethod {22    /**23     * Get all defined Strings from an app for the default language.24     *25     * @return a map with localized strings defined in the app26     */27    default Map<String, String> getAppStringMap() {28        return CommandExecutionHelper.execute(this, GET_STRINGS);29    }30    /**31     * Get all defined Strings from an app for the specified language.32     *33     * @param language strings language code34     * @return a map with localized strings defined in the app35     */...

Full Screen

Full Screen

MobileApplication.java

Source:MobileApplication.java Github

copy

Full Screen

1package com.github.arachnidium.model.mobile;23import io.appium.java_client.AppiumDriver;4import io.appium.java_client.DeviceActionShortcuts;5import io.appium.java_client.HasAppStrings;67import org.openqa.selenium.html5.Location;8import org.openqa.selenium.html5.LocationContext;910import com.github.arachnidium.core.HowToGetMobileScreen;11import com.github.arachnidium.core.MobileScreen;12import com.github.arachnidium.core.ScreenManager;13import com.github.arachnidium.model.common.Application;1415/**16 * Representation of a mobile application17 * 18 * @see Application19 */20public abstract class MobileApplication extends Application<MobileScreen, 21    HowToGetMobileScreen> implements DeviceActionShortcuts, LocationContext, HasAppStrings {2223	protected MobileApplication(MobileScreen context) {24		super(context);25	}2627	@SuppressWarnings("unchecked")28	@Override29	public ScreenManager getManager() {30		return (ScreenManager) super.getManager();31	}3233	@Override34	public void hideKeyboard() {35		((AppiumDriver<?>) getWrappedDriver()).hideKeyboard();		
...

Full Screen

Full Screen

HasAppStrings

Using AI Code Generation

copy

Full Screen

1HasAppStrings hasAppStrings = (HasAppStrings) driver;2Map<String, String> appStrings = hasAppStrings.getAppStringMap();3System.out.println(appStrings.get("CFBundleDisplayName"));4System.out.println(appStrings.get("CFBundleIdentifier"));5System.out.println(appStrings.get("CFBundleName"));6System.out.println(appStrings.get("CFBundleShortVersionString"));7System.out.println(appStrings.get("CFBundleVersion"));8System.out.println(appStrings.get("LSApplicationQueriesSchemes"));9IHasAppStrings hasAppStrings = (IHasAppStrings) driver;10Dictionary<string, string> appStrings = hasAppStrings.AppStringMap;11Console.WriteLine(appStrings["CFBundleDisplayName"]);12Console.WriteLine(appStrings["CFBundleIdentifier"]);13Console.WriteLine(appStrings["CFBundleName"]);14Console.WriteLine(appStrings["CFBundleShortVersionString"]);15Console.WriteLine(appStrings["CFBundleVersion"]);16Console.WriteLine(appStrings["LSApplicationQueriesSchemes"]);17print(app_strings['CFBundleDisplayName'])18print(app_strings['CFBundleIdentifier'])19print(app_strings['CFBundleName'])20print(app_strings['CFBundleShortVersionString'])21print(app_strings['CFBundleVersion'])22print(app_strings['LSApplicationQueriesSchemes'])23$has_app_strings = new HasAppStrings($driver);24$app_strings = $has_app_strings->appStringMap();25echo $app_strings['CFBundleDisplayName'];26echo $app_strings['CFBundleIdentifier'];27echo $app_strings['CFBundleName'];

Full Screen

Full Screen

HasAppStrings

Using AI Code Generation

copy

Full Screen

1HasAppStrings hasAppStrings = (HasAppStrings) driver;2Map<String, String> appStrings = hasAppStrings.getAppStringMap();3from appium.webdriver.common.mobileby import MobileBy4from appium.webdriver.common.touch_action import TouchAction5from appium.webdriver.common.multi_action import MultiAction6from appium.webdriver.common.touch_action import ElementOption7appStrings = hasAppStrings.get_app_strings()8var hasAppStrings = driver;9var appStrings = hasAppStrings.getAppStrings();10appStrings = hasAppStrings.getAppStrings()11$hasAppStrings = $driver;12$appStrings = $hasAppStrings->getAppStrings();13IHasAppStrings hasAppStrings = (IHasAppStrings)driver;14Dictionary<string, string> appStrings = hasAppStrings.GetAppStringMap();15my $hasAppStrings = $driver;16my $appStrings = $hasAppStrings->getAppStrings();17appStrings := hasAppStrings.GetAppStrings()

Full Screen

Full Screen

HasAppStrings

Using AI Code Generation

copy

Full Screen

1package com.appium.tests;2import io.appium.java_client.HasAppStrings;3import io.appium.java_client.android.AndroidDriver;4import java.net.URL;5import org.openqa.selenium.By;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.remote.DesiredCapabilities;8public class AppStrings {9	public static void main(String[] args) throws Exception {10		DesiredCapabilities capabilities = new DesiredCapabilities();11		capabilities.setCapability("deviceName", "Android Device");12		capabilities.setCapability("browserName", "Android");13		capabilities.setCapability("platformVersion", "4.4");14		capabilities.setCapability("platformName", "Android");15		capabilities.setCapability("appPackage", "com.android.calculator2");16		capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

HasAppStrings

Using AI Code Generation

copy

Full Screen

1HasAppStrings hasAppStrings = (HasAppStrings) driver;2Map<String, String> appStrings = hasAppStrings.getAppStrings("en");3System.out.println(appStrings.get("CFBundleDisplayName"));4hasAppStrings = HasAppStrings(driver)5appStrings = hasAppStrings.getAppStrings("en")6print(appStrings.get("CFBundleDisplayName"))7const hasAppStrings = new HasAppStrings(driver);8const appStrings = hasAppStrings.getAppStrings("en");9console.log(appStrings.get("CFBundleDisplayName"));10hasAppStrings = Appium::Core::HasAppStrings.new(driver)11appStrings = hasAppStrings.getAppStrings("en")12puts appStrings.get("CFBundleDisplayName")13$hasAppStrings = new HasAppStrings($driver);14$appStrings = $hasAppStrings->getAppStrings("en");15echo $appStrings->get("CFBundleDisplayName");16hasAppStrings = new Appium::Core::HasAppStrings(driver)17appStrings = hasAppStrings.getAppStrings("en")18console.log appStrings.get("CFBundleDisplayName")19$hasAppStrings = Appium::Core::HasAppStrings->new($driver);20$appStrings = $hasAppStrings->getAppStrings("en");21print $appStrings->get("CFBundleDisplayName");22hasAppStrings := Appium::Core::HasAppStrings{driver}23appStrings := hasAppStrings.GetAppStrings("en")24fmt.Println(appStrings.Get("CFBundleDisplayName"))

Full Screen

Full Screen

HasAppStrings

Using AI Code Generation

copy

Full Screen

1public class AppiumTest extends BaseClass {2    public void testAppStrings() {3        HasAppStrings hasAppStrings = (HasAppStrings) driver;4        Map<String, String> appStrings = hasAppStrings.getAppStrings();5        System.out.println(appStrings);6    }7}8package com.test.automation;9import io.appium.java_client.android.AndroidDriver;10import org.openqa.selenium.remote.DesiredCapabilities;11import java.net.MalformedURLException;12import java.net.URL;13public class BaseClass {14    public static AndroidDriver driver;15    public static void setDriver() throws MalformedURLException {16        DesiredCapabilities capabilities = new DesiredCapabilities();17        capabilities.setCapability("deviceName", "Your device name");18        capabilities.setCapability("platformName", "Android");19        capabilities.setCapability("platformVersion", "Your device platform version");20        capabilities.setCapability("appPackage", "Your app package name");21        capabilities.setCapability("appActivity", "Your app activity name");22        capabilities.setCapability("noReset", "true");

Full Screen

Full Screen

HasAppStrings

Using AI Code Generation

copy

Full Screen

1driver.getAppStrings("en");2driver.getAppStrings("en", "strings.json");3driver.getAppStrings("en");4driver.getAppStrings("en", "strings.json");5driver.get_app_strings("en")6driver.get_app_strings("en", "strings.json")7driver.get_app_strings("en")8driver.get_app_strings("en", "strings.json")9$driver->getAppStrings("en");10$driver->getAppStrings("en", "strings.json");11driver.AppStrings("en");12driver.AppStrings("en", "strings.json");13driver.get_app_strings("en")14driver.get_app_strings("en", "strings.json")15driver.AppStrings("en")16driver.AppStrings("en", "strings.json")17driver.getAppStrings("en")18driver.getAppStrings("en", "strings.json")19driver.AppStrings("en");20driver.AppStrings("en", "strings.json");21driver.getAppStrings("en");22driver.getAppStrings("en", "strings.json");23driver.get_app_strings("en")24driver.get_app_strings("en", "strings

Full Screen

Full Screen

HasAppStrings

Using AI Code Generation

copy

Full Screen

1package appium;2import java.util.List;3import java.util.Map;4import org.openqa.selenium.remote.DesiredCapabilities;5import org.testng.annotations.BeforeTest;6import org.testng.annotations.Test;7import io.appium.java_client.AppiumDriver;8import io.appium.java_client.HasAppStrings;9import io.appium.java_client.MobileElement;10import io.appium.java_client.android.AndroidDriver;11import io.appium.java_client.remote.MobileCapabilityType;12public class AppStrings {13    public AppiumDriver<MobileElement> driver;14    public void setup() throws Exception {15        DesiredCapabilities capabilities = new DesiredCapabilities();16        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");17        capabilities.setCapability(MobileCapabilityType.APP, "C:\\Users\\user\\Downloads\\ApiDemos-debug.apk");18        driver = new AndroidDriver<MobileElement>(capabilities);19    }20    public void appStrings() throws Exception {21        HasAppStrings hasAppStrings = (HasAppStrings) driver;22        Map<String, String> appStrings = hasAppStrings.getAppStringMap();23        System.out.println(appStrings);24        List<String> appStrings2 = hasAppStrings.getAppStringList();25        System.out.println(appStrings2);26    }27}28{android:id/autofill_save_no:No, android:id/autofill_save_yes:Yes, android:id/autofill_save_title:Save password?, android:id/autofill_save_message:Would you like to save the password for example.com?, android:id/autofill_save_dontsave:Don't save, android:id/autofill_save_always:Always, android:id/autofill_save_never:Never, android:id/autofill_save_ask:Ask, android:id/autofill_save_notnow:Not now, android:id/autofill_save_generic_username:Username, android:id/autofill_save_generic_password:Password, android:id/autofill_save_generic_email:Email, android:id/autofill_save_generic_phone:Phone, android:id/autofill_save_generic_name:Name, android:id/autofill_save_generic_address:Address, android:id/autofill_save_generic_credit_card_number:Credit card number, android:id/autofill_save_generic_credit_card_expiration_date:Credit card expiration date, android:id/autofill_save_generic

Full Screen

Full Screen

HasAppStrings

Using AI Code Generation

copy

Full Screen

1Map<String, String> appStrings = ((HasAppStrings) driver).appStrings();2Map<String, String> appStrings = ((HasAppStrings) driver).appStrings("en");3Map<String, String> appStrings = ((HasAppStrings) driver).appStrings("en", "Localizable");4app_strings = driver.app_strings()5app_strings = driver.app_strings("en")6app_strings = driver.app_strings("en", "Localizable")7app_strings = @driver.app_strings('en')8app_strings = @driver.app_strings('en', 'Localizable')9app_strings = app_strings(driver)10app_strings = app_strings(driver, "en")11app_strings = app_strings(driver, "en", "Localizable")12$appStrings = $driver->appStrings();13$appStrings = $driver->appStrings('en');14$appStrings = $driver->appStrings('en', 'Localizable');15const appStrings = await driver.appStrings();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in HasAppStrings

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful