How to use getAppiumDriver method of org.cerberus.engine.entity.Session class

Best Cerberus-source code snippet using org.cerberus.engine.entity.Session.getAppiumDriver

Source:AppiumService.java Github

copy

Full Screen

...65 private ParameterService parameters;66 @Override67 public MessageEvent switchToContext(Session session, Identifier identifier) {68 MessageEvent message;69 AppiumDriver driver = session.getAppiumDriver();70 String newContext = "";71 Set<String> contextNames = driver.getContextHandles();72 for (String contextName : contextNames) {73 LOG.error("Context : " + contextName);74 if (contextName.contains("WEBVIEW")) {75 driver.context(contextName);76 newContext = contextName;77 break;78 }79 }80 //driver.context("WEBVIEW_1");81 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SWITCHTOWINDOW);82 message.setDescription(message.getDescription().replace("%WINDOW%", newContext));83 return message;84 }85 @Override86 public MessageEvent type(Session session, Identifier identifier, String property, String propertyName) {87 MessageEvent message;88 try {89 if (!StringUtil.isNull(property)) {90 TouchAction action = new TouchAction(session.getAppiumDriver());91 action.press(this.getElement(session, identifier, false, false)).release().perform();92 session.getAppiumDriver().getKeyboard().pressKey(property);93 }94 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_TYPE);95 message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));96 if (!StringUtil.isNull(property)) {97 message.setDescription(message.getDescription().replace("%DATA%", ParameterParserUtil.securePassword(property, propertyName)));98 } else {99 message.setDescription(message.getDescription().replace("%DATA%", "No property"));100 }101 return message;102 } catch (NoSuchElementException exception) {103 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_TYPE_NO_SUCH_ELEMENT);104 message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));105 LOG.debug(exception.toString());106 return message;107 } catch (WebDriverException exception) {108 LOG.fatal(exception.toString());109 return parseWebDriverException(exception);110 }111 }112 @Override113 public MessageEvent click(final Session session, final Identifier identifier) {114 try {115 final TouchAction action = new TouchAction(session.getAppiumDriver());116 if (identifier.isSameIdentifier(Identifier.Identifiers.COORDINATE)) {117 final Coordinates coordinates = getCoordinates(identifier);118 action.tap(coordinates.getX(), coordinates.getY()).perform();119 } else {120 action.tap(getElement(session, identifier, false, false)).perform();121 }122 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_CLICK).resolveDescription("ELEMENT", identifier.toString());123 } catch (NoSuchElementException e) {124 if (LOG.isDebugEnabled()) {125 LOG.debug(e.getMessage());126 }127 return new MessageEvent(MessageEventEnum.ACTION_FAILED_CLICK_NO_SUCH_ELEMENT).resolveDescription("ELEMENT", identifier.toString());128 } catch (WebDriverException e) {129 LOG.warn(e.getMessage());130 return parseWebDriverException(e);131 }132 }133 /**134 * @author vertigo17135 * @param exception the exception need to be parsed by Cerberus136 * @return A new Event Message with selenium related description137 */138 private MessageEvent parseWebDriverException(WebDriverException exception) {139 MessageEvent mes;140 LOG.fatal(exception.toString());141 mes = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELENIUM_CONNECTIVITY);142 mes.setDescription(mes.getDescription().replace("%ERROR%", exception.getMessage().split("\n")[0]));143 return mes;144 }145 /**146 * Get the {@link Coordinates} represented by the given {@link Identifier}147 *148 * @param identifier the {@link Identifier} to parse to get the149 * {@link Coordinates}150 * @return the {@link Coordinates} represented by the given151 * {@link Identifier}152 * @throws NoSuchElementException if no {@link Coordinates} can be found153 * inside the given {@link Identifier}154 */155 private Coordinates getCoordinates(final Identifier identifier) {156 if (identifier == null || !identifier.isSameIdentifier(Identifier.Identifiers.COORDINATE)) {157 throw new NoSuchElementException("Unable to get coordinates from a non coordinates identifier");158 }159 final Matcher coordinates = Identifier.Identifiers.COORDINATE_VALUE_PATTERN.matcher(identifier.getLocator());160 if (!coordinates.find()) {161 throw new NoSuchElementException("Bad coordinates format");162 }163 try {164 return new Coordinates(165 Integer.valueOf(coordinates.group("xCoordinate")),166 Integer.valueOf(coordinates.group("yCoordinate"))167 );168 } catch (NumberFormatException e) {169 throw new NoSuchElementException("Bad coordinates format", e);170 }171 }172 private By getBy(Identifier identifier) {173 LOG.debug("Finding selenium Element : " + identifier.getLocator() + " by : " + identifier.getIdentifier());174 if (identifier.getIdentifier().equalsIgnoreCase("id")) {175 return By.id(identifier.getLocator());176 } else if (identifier.getIdentifier().equalsIgnoreCase("name")) {177 return By.name(identifier.getLocator());178 } else if (identifier.getIdentifier().equalsIgnoreCase("class")) {179 return By.className(identifier.getLocator());180 } else if (identifier.getIdentifier().equalsIgnoreCase("css")) {181 return By.cssSelector(identifier.getLocator());182 } else if (identifier.getIdentifier().equalsIgnoreCase("xpath")) {183 return By.xpath(identifier.getLocator());184 } else if (identifier.getIdentifier().equalsIgnoreCase("link")) {185 return By.linkText(identifier.getLocator());186 } else if (identifier.getIdentifier().equalsIgnoreCase("data-cerberus")) {187 return By.xpath("//*[@data-cerberus='" + identifier.getLocator() + "']");188 } else {189 throw new NoSuchElementException(identifier.getIdentifier());190 }191 }192 private WebElement getElement(Session session, Identifier identifier, boolean visible, boolean clickable) {193 AppiumDriver driver = session.getAppiumDriver();194 By locator = this.getBy(identifier);195 LOG.debug("Waiting for Element : " + identifier.getIdentifier() + "=" + identifier.getLocator());196 try {197 WebDriverWait wait = new WebDriverWait(driver, TimeUnit.MILLISECONDS.toSeconds(session.getCerberus_appium_wait_element()));198 if (visible) {199 if (clickable) {200 wait.until(ExpectedConditions.elementToBeClickable(locator));201 } else {202 wait.until(ExpectedConditions.visibilityOfElementLocated(locator));203 }204 } else {205 wait.until(ExpectedConditions.presenceOfElementLocated(locator));206 }207 } catch (TimeoutException exception) {208 LOG.fatal("Exception waiting for element :" + exception.toString());209 throw new NoSuchElementException(identifier.getIdentifier() + "=" + identifier.getLocator());210 }211 LOG.debug("Finding Element : " + identifier.getIdentifier() + "=" + identifier.getLocator());212 return driver.findElement(locator);213 }214 /**215 *216 * @param session217 * @param action218 * @return219 * @throws IllegalArgumentException220 */221 @Override222 public Direction getDirectionForSwipe(Session session, SwipeAction action) throws IllegalArgumentException {223 Dimension window = session.getAppiumDriver().manage().window().getSize();224 SwipeAction.Direction direction;225 switch (action.getActionType()) {226 case UP:227 direction = SwipeAction.Direction.fromLine(228 new Line2D.Double(229 window.getWidth() / 2,230 2 * window.getHeight() / 3,231 0,232 - window.getHeight() / 3233 )234 );235 break;236 case DOWN:237 direction = SwipeAction.Direction.fromLine(...

Full Screen

Full Screen

Source:IOSAppiumService.java Github

copy

Full Screen

...83 return new MessageEvent(MessageEventEnum.ACTION_FAILED_KEYPRESS_NOT_AVAILABLE).resolveDescription("KEY", keyName);84 }85 // Then do the key press86 try {87 session.getAppiumDriver().getKeyboard().pressKey(keyToPress.getCode());88 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_KEYPRESS_NO_ELEMENT).resolveDescription("KEY", keyName);89 } catch (Exception e) {90 LOG.warn("Unable to key press due to " + e.getMessage());91 return new MessageEvent(MessageEventEnum.ACTION_FAILED_KEYPRESS_OTHER)92 .resolveDescription("KEY", keyName)93 .resolveDescription("REASON", e.getMessage());94 }95 }96 /**97 * Due to98 * https://discuss.appium.io/t/appium-ios-guide-hiding-the-keyboard-on-real-devices/8221,99 * IOS keyboard can be only hidden by taping on a keyboard key. As same as100 * the tutorial, the {@link Keys#RETURN} (so the {@link KeyCode#RETURN} in101 * Cerberus language) is used to hide keyboard.102 *103 * @param session104 * @return105 */106 @Override107 public MessageEvent hideKeyboard(Session session) {108 MessageEvent keyPressResult = keyPress(session, KeyCode.RETURN.name());109 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_KEYPRESS_NO_ELEMENT.equals(keyPressResult.getSource())110 ? MessageEventEnum.ACTION_SUCCESS_HIDEKEYBOARD111 : MessageEventEnum.ACTION_FAILED_HIDEKEYBOARD);112 }113 /**114 * The only valid IOS key codes to be able to be pressed115 * <p>116 * See https://github.com/appium/java-client/issues/402 for more information117 */118 private enum KeyCode {119 RETURN(Keys.RETURN.toString()),120 ENTER(Keys.ENTER.toString()),121 SEARCH(Keys.ENTER.toString()),122 BACKSPACE(Keys.BACK_SPACE.toString());123 private String code;124 KeyCode(String code) {125 this.code = code;126 }127 public String getCode() {128 return code;129 }130 }131 @Override132 public MessageEvent swipe(Session session, SwipeAction action) {133 try {134 Direction direction = this.getDirectionForSwipe(session, action);135 // Get the parametrized swipe duration136 Integer myduration = parameters.getParameterIntegerByKey(CERBERUS_APPIUM_SWIPE_DURATION_PARAMETER, "", DEFAULT_CERBERUS_APPIUM_SWIPE_DURATION);137 // Do the swipe thanks to the Appium driver138 TouchAction dragNDrop139 = new TouchAction(session.getAppiumDriver()).press(PointOption.point(direction.getX1(), direction.getY1())).waitAction(WaitOptions.waitOptions(Duration.ofMillis(myduration)))140 .moveTo(PointOption.point(direction.getX2(), direction.getY2())).release();141 dragNDrop.perform();142// JavascriptExecutor js = (JavascriptExecutor) session.getAppiumDriver();143// HashMap<String, Integer> swipeObject = new HashMap<String, Integer>();144// swipeObject.put("startX", direction.getX1());145// swipeObject.put("startY", direction.getY1());146// swipeObject.put("endX", direction.getX2());147// swipeObject.put("endY", direction.getY2());148// swipeObject.put("duration", myduration);149// js.executeScript("mobile: swipe", swipeObject);150 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SWIPE).resolveDescription("DIRECTION", action.getActionType().name());151 } catch (IllegalArgumentException e) {152 return new MessageEvent(MessageEventEnum.ACTION_FAILED_SWIPE)153 .resolveDescription("DIRECTION", action.getActionType().name())154 .resolveDescription("REASON", "Unknown direction");155 } catch (Exception e) {156 LOG.warn("Unable to swipe screen due to " + e.getMessage(), e);157 return new MessageEvent(MessageEventEnum.ACTION_FAILED_SWIPE)158 .resolveDescription("DIRECTION", action.getActionType().name())159 .resolveDescription("REASON", e.getMessage());160 }161 }162 @Override163 public MessageEvent executeCommand(Session session, String cmd, String args) throws IllegalArgumentException {164 try {165 String message = executeCommandString(session, cmd, args);166 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_EXECUTECOMMAND).resolveDescription("LOG", message);167 } catch (Exception e) {168 LOG.warn("Unable to execute command screen due to " + e.getMessage(), e);169 return new MessageEvent(MessageEventEnum.ACTION_FAILED_EXECUTECOMMAND)170 .resolveDescription("EXCEPTION", e.getMessage());171 }172 }173 @Override174 public String executeCommandString(Session session, String cmd, String args) throws IllegalArgumentException, JSONException {175 Object value;176 String valueString = "";177 if (StringUtil.isNullOrEmpty(args)) {178 value = session.getAppiumDriver().executeScript(cmd, new HashMap<>());179 } else {180 value = session.getAppiumDriver().executeScript(cmd, JSONUtil.convertFromJSONObjectString(args));181 }182 if (value != null) {183 valueString = value.toString();184 }185 // execute Script return an \n or \r\n sometimes, so we delete the last occurence of it186 if (!StringUtil.isNullOrEmpty(valueString)) {187 if (valueString.endsWith("\r\n")) {188 valueString = valueString.substring(0, valueString.lastIndexOf("\r\n"));189 }190 if (valueString.endsWith("\n")) {191 valueString = valueString.substring(0, valueString.lastIndexOf('\n'));192 }193 }194 return valueString;195 }196 @Override197 public MessageEvent installApp(Session session, String appPath) throws IllegalArgumentException {198 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);199 }200 @Override201 public MessageEvent removeApp(Session session, String appPackage) throws IllegalArgumentException {202 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);203 }204 @Override205 public MessageEvent openApp(Session session, String appPackage, String appActivity) {206 try {207 if (StringUtil.isNullOrEmpty(appPackage)) {208 session.getAppiumDriver().launchApp();209 } else {210 session.getAppiumDriver().activateApp(appPackage);211 }212 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_OPENAPP).resolveDescription("APP", appPackage);213 } catch (Exception e) {214 LOG.warn("Unable to open app. " + e.getMessage(), e);215 return new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC)216 .resolveDescription("DETAIL", "Unable to open app " + e.getMessage());217 }218 }219 @Override220 public MessageEvent closeApp(Session session) {221 try {222 session.getAppiumDriver().closeApp();223 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_CLOSEAPP_GENERIC);224 } catch (Exception e) {225 LOG.warn("Unable to close app " + e.getMessage(), e);226 return new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC)227 .resolveDescription("DETAIL", "Unable to close app : " + e.getMessage());228 }229 }230}...

Full Screen

Full Screen

Source:AndroidAppiumService.java Github

copy

Full Screen

...72 @Override73 public MessageEvent keyPress(Session session, String keyName) {74 // Then press the key75 try {76 ((PressesKey) session.getAppiumDriver()).pressKey(new KeyEvent(AndroidKey.valueOf(keyName)));77 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_KEYPRESS_NO_ELEMENT).resolveDescription("KEY", keyName);78 } catch (IllegalArgumentException e) {79 return new MessageEvent(MessageEventEnum.ACTION_FAILED_KEYPRESS_NOT_AVAILABLE).resolveDescription("KEY", keyName);80 } catch (Exception e) {81 LOG.warn("Unable to key press due to " + e.getMessage(), e);82 return new MessageEvent(MessageEventEnum.ACTION_FAILED_KEYPRESS_OTHER)83 .resolveDescription("KEY", keyName)84 .resolveDescription("REASON", e.getMessage());85 }86 }87 @Override88 public MessageEvent hideKeyboard(Session session) {89 try {90 session.getAppiumDriver().hideKeyboard();91 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_HIDEKEYBOARD);92 } catch (Exception e) {93 // Instead of http://stackoverflow.com/questions/35030794/soft-keyboard-not-present-cannot-hide-keyboard-appium-android?answertab=votes#tab-top94 // and testing if keyboard is already hidden by executing an ADB command,95 // we prefer to parse error message to know if it's just due to keyboard which is already hidden.96 // This way, we are more portable because it is not necessary to connect to the Appium server and send the ADB command.97 if (IS_KEYBOARD_ABSENT_ERROR_PATTERN.matcher(e.getMessage()).find()) {98 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_HIDEKEYBOARD_ALREADYHIDDEN);99 }100 LOG.warn("Unable to hide keyboard due to " + e.getMessage(), e);101 return new MessageEvent(MessageEventEnum.ACTION_FAILED_HIDEKEYBOARD);102 }103 }104 @Override105 public MessageEvent swipe(Session session, SwipeAction action) {106 try {107 SwipeAction.Direction direction = this.getDirectionForSwipe(session, action);108 // Get the parametrized swipe duration109 Parameter duration = parameters.findParameterByKey(CERBERUS_APPIUM_SWIPE_DURATION_PARAMETER, "");110 // Do the swipe thanks to the Appium driver111 TouchAction dragNDrop112 = new TouchAction(session.getAppiumDriver()).press(PointOption.point(direction.getX1(), direction.getY1())).waitAction(WaitOptions.waitOptions(Duration.ofMillis(duration == null ? DEFAULT_CERBERUS_APPIUM_SWIPE_DURATION : Integer.parseInt(duration.getValue()))))113 .moveTo(PointOption.point(direction.getX2(), direction.getY2())).release();114 dragNDrop.perform();115 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SWIPE).resolveDescription("DIRECTION", action.getActionType().name());116 } catch (IllegalArgumentException e) {117 return new MessageEvent(MessageEventEnum.ACTION_FAILED_SWIPE)118 .resolveDescription("DIRECTION", action.getActionType().name())119 .resolveDescription("REASON", "Unknown direction");120 } catch (Exception e) {121 LOG.warn("Unable to swipe screen due to " + e.getMessage(), e);122 return new MessageEvent(MessageEventEnum.ACTION_FAILED_SWIPE)123 .resolveDescription("DIRECTION", action.getActionType().name())124 .resolveDescription("REASON", e.getMessage());125 }126 }127 @Override128 public MessageEvent executeCommand(Session session, String cmd, String args) throws IllegalArgumentException {129 try {130 String message = executeCommandString(session, cmd, args);131 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_EXECUTECOMMAND).resolveDescription("LOG", message);132 } catch (Exception e) {133 LOG.warn("Unable to execute command screen due to " + e.getMessage(), e);134 return new MessageEvent(MessageEventEnum.ACTION_FAILED_EXECUTECOMMAND)135 .resolveDescription("EXCEPTION", e.getMessage());136 }137 }138 @Override139 public String executeCommandString(Session session, String cmd, String args) throws IllegalArgumentException, JSONException {140 Object value;141 String valueString = "";142 if (StringUtil.isNullOrEmpty(args)) {143 value = session.getAppiumDriver().executeScript(cmd, new HashMap<>());144 } else {145 value = session.getAppiumDriver().executeScript(cmd, JSONUtil.convertFromJSONObjectString(args));146 }147 if (value != null) {148 valueString = value.toString();149 }150 // execute Script return an \n or \r\n sometimes, so we delete the last occurence of it151 if (!StringUtil.isNullOrEmpty(valueString)) {152 if (valueString.endsWith("\r\n")) {153 valueString = valueString.substring(0, valueString.lastIndexOf("\r\n"));154 }155 if (valueString.endsWith("\n")) {156 valueString = valueString.substring(0, valueString.lastIndexOf('\n'));157 }158 }159 return valueString;160 }161 @Override162 public MessageEvent installApp(Session session, String appPath) throws IllegalArgumentException {163 try {164 AndroidDriver driver = ((AndroidDriver) session.getAppiumDriver());165 driver.installApp(appPath);166 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_INSTALLAPP);167 } catch (Exception e) {168 LOG.warn("Unable to install app " + e.getMessage(), e);169 return new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC)170 .resolveDescription("DETAIL", "Unable to install app " + e.getMessage());171 }172 }173 @Override174 public MessageEvent removeApp(Session session, String appPackage) throws IllegalArgumentException {175 try {176 AndroidDriver driver = ((AndroidDriver) session.getAppiumDriver());177 if (driver.isAppInstalled(appPackage)) {178 driver.removeApp(appPackage);179 }180 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_REMOVEAPP);181 } catch (Exception e) {182 LOG.warn("Unable to remove app " + e.getMessage(), e);183 return new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC)184 .resolveDescription("DETAIL", "Unable to remove app " + e.getMessage());185 }186 }187 @Override188 public MessageEvent openApp(Session session, String appPackage, String appActivity) {189 return executeCommand(session, "mobile:shell", "{'command': 'am start', 'args': ['-n " + appPackage + "/" + appActivity + "\n']}");190 }191 @Override192 public MessageEvent closeApp(Session session) {193 try {194 session.getAppiumDriver().closeApp();195 return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_CLOSEAPP_GENERIC);196 } catch (Exception e) {197 LOG.warn("Unable to close app " + e.getMessage(), e);198 return new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC)199 .resolveDescription("DETAIL", "Unable to close app : " + e.getMessage());200 }201 }202}...

Full Screen

Full Screen

getAppiumDriver

Using AI Code Generation

copy

Full Screen

1package org.cerberus.engine.entity;2import java.net.MalformedURLException;3import java.net.URL;4import java.util.HashMap;5import java.util.Map;6import org.openqa.selenium.By;7import org.openqa.selenium.WebDriver;8import org.openqa.selenium.WebElement;9import org.openqa.selenium.remote.CapabilityType;10import org.openqa.selenium.remote.DesiredCapabilities;11import org.openqa.selenium.remote.RemoteWebDriver;12public class Session {13 private static WebDriver driver;

Full Screen

Full Screen

getAppiumDriver

Using AI Code Generation

copy

Full Screen

1import java.net.MalformedURLException;2import java.net.URL;3import org.openqa.selenium.remote.DesiredCapabilities;4import org.openqa.selenium.remote.RemoteWebDriver;5import org.testng.annotations.Test;6import io.appium.java_client.AppiumDriver;7import org.cerberus.engine.entity.Session;8public class 3 {9public void test() throws MalformedURLException {10DesiredCapabilities capabilities = new DesiredCapabilities();11capabilities.setCapability("deviceName", "My Phone");12capabilities.setCapability("browserName", "Android");13capabilities.setCapability("platformVersion", "6.0.1");14capabilities.setCapability("platformName", "Android");15capabilities.setCapability("appPackage", "com.android.calculator2");16capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

getAppiumDriver

Using AI Code Generation

copy

Full Screen

1package com.cerberus.test;2import org.cerberus.engine.entity.Session;3import org.cerberus.engine.entity.TestCase;4import org.cerberus.engine.entity.TestStep;5import org.cerberus.engine.entity.TestStepAction;6import org.cerberus.engine.entity.TestStepActionControl;7import org.cerberus.engine.entity.TestStepActionControlExecution;8import org.cerberus.engine.entity.TestStepActionExecution;9import org.cerberus.engine.entity.TestStepExecution;10import org.cerberus.engine.execution.IExecution;11import org.cerberus.engine.execution.impl.Execution;12import org.cerberus.engine.execution.impl.TestStepActionExecutionService;13import org.cerberus.engine.execution.impl.TestStepExecutionService;14import org.cerberus.engine.execution.impl.TestCaseExecutionService;15import org.cerberus.engine.execution.impl.TestStepActionControlExecutionService;16import org.openqa.selenium.By;17import org.openqa.selenium.WebDriver;18import org.openqa.selenium.WebElement;19import org.openqa.selenium.remote.DesiredCapabilities;20import org.openqa.selenium.support.ui.ExpectedConditions;21import org.openqa.selenium.support.ui.WebDriverWait;22import io.appium.java_client.AppiumDriver;23import io.appium.java_client.MobileElement;24import io.appium.java_client.android.AndroidDriver;25import java.net.MalformedURLException;26import java.net.URL;27import java.util.ArrayList;28import java.util.List;29public class Test {30public static void main(String[] args) throws MalformedURLException, InterruptedException {31 DesiredCapabilities capabilities = new DesiredCapabilities();32 capabilities.setCapability("deviceName", "Redmi 4A");33 capabilities.setCapability("udid", "b3d1e3c3");34 capabilities.setCapability("platformName", "Android");35 capabilities.setCapability("platformVersion", "7.1.2");36 capabilities.setCapability("appPackage", "com.android.calculator2");37 capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");38 capabilities.setCapability("noReset", "true");

Full Screen

Full Screen

getAppiumDriver

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.AppiumDriver;2import io.appium.java_client.MobileElement;3import org.openqa.selenium.By;4import org.openqa.selenium.WebElement;5import org.openqa.selenium.remote.DesiredCapabilities;6import org.cerberus.engine.entity.Session;7import java.net.URL;8import java.util.concurrent.TimeUnit;9public class 3 {10public static void main(String[] args) throws Exception {11DesiredCapabilities capabilities = new DesiredCapabilities();12capabilities.setCapability("deviceName", "My Phone");13capabilities.setCapability("BROWSER_NAME", "Android");14capabilities.setCapability("VERSION", "8.1.0");15capabilities.setCapability("platformName", "Android");16capabilities.setCapability("appPackage", "com.android.calculator2");17capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

getAppiumDriver

Using AI Code Generation

copy

Full Screen

1public class 3 {2 public static void main(String[] args) {3 AppiumDriver driver = Session.getSession().getAppiumDriver();4 driver.findElement(By.id("com.android.calculator2:id/digit_1")).click();5 driver.findElement(By.id("com.android.calculator2:id/digit_2")).click();6 driver.findElement(By.id("com.android.calculator2:id/digit_3")).click();7 driver.findElement(By.id("com.android.calculator2:id/digit_4")).click();8 driver.findElement(By.id("com.android.calculator2:id/digit_5")).click();9 driver.findElement(By.id("com.android.calculator2:id/digit_6")).click();10 driver.findElement(By.id("com.android.calculator2:id/digit_7")).click();11 driver.findElement(By.id("com.android.calculator2:id/digit_8")).click();12 driver.findElement(By.id("com.android.calculator2:id/digit_9")).click();13 driver.findElement(By.id("com.android.calculator2:id/digit_0")

Full Screen

Full Screen

getAppiumDriver

Using AI Code Generation

copy

Full Screen

1Session session = new Session();2AppiumDriver driver = session.getAppiumDriver();3driver.findElement(By.id("someID")).click();4driver.findElement(By.id("someID")).sendKeys("some text");5Session session = new Session();6AppiumDriver driver = session.getAppiumDriver();7driver.findElement(By.id("someID")).click();8driver.findElement(By.id("someID")).sendKeys("some text");9Session session = new Session();10AppiumDriver driver = session.getAppiumDriver();11driver.findElement(By.id("someID")).click();12driver.findElement(By.id("someID")).sendKeys("some text");13Session session = new Session();14AppiumDriver driver = session.getAppiumDriver();15driver.findElement(By.id("someID")).click();16driver.findElement(By.id("someID")).sendKeys("some text");17Session session = new Session();18AppiumDriver driver = session.getAppiumDriver();19driver.findElement(By.id("someID")).click();20driver.findElement(By.id("someID")).sendKeys("some text");21Session session = new Session();22AppiumDriver driver = session.getAppiumDriver();23driver.findElement(By.id("someID")).click();24driver.findElement(By.id("someID")).sendKeys("some text");

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 Cerberus-source automation tests on LambdaTest cloud grid

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

Most used method in Session

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful