How to use AutomationName class of io.appium.java_client.remote package

Best io.appium code snippet using io.appium.java_client.remote.AutomationName

Capability.java

Source:Capability.java Github

copy

Full Screen

...10import org.openqa.selenium.remote.DesiredCapabilities;11import io.appium.java_client.android.AndroidDriver;12import io.appium.java_client.android.AndroidElement;13import io.appium.java_client.remote.AndroidMobileCapabilityType;14import io.appium.java_client.remote.AutomationName;15import io.appium.java_client.remote.MobileCapabilityType;16import io.appium.java_client.service.local.AppiumDriverLocalService;17import io.appium.java_client.service.local.AppiumServiceBuilder;18public class Capability {19 protected static String appPackage;20 protected static String appActivity;21 protected static String deviceName;22 protected static String chromedriverExecutable;23 public AppiumDriverLocalService service;24 // creating this method to start my appium through nodejs // this is given by appium server25 public AppiumDriverLocalService startServer()26 {27 boolean flag = checkifserverisRunning(4723);28 if(!flag)29 { 30 //service = AppiumDriverLocalService.buildDefaultService();31 service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()32 .usingDriverExecutable(new File("C:\\Program Files\\nodejs\\node.exe"))33 .withAppiumJS(new File("C:\\Users\\ShashankCN\\AppData\\Roaming\\npm\\node_modules\\appium\\build\\lib\\main.js"))34 .withIPAddress("127.0.0.1").usingPort(4723)); 35 service.start();36 }37 return service; 38 }39 40 public static boolean checkifserverisRunning(int port)41 {42 boolean isserverRunning = false;43 ServerSocket serverSocket;44 try45 {46 serverSocket = new ServerSocket(port);47 serverSocket.close();48 }49 catch (Exception e) {50 isserverRunning= true;51 }52 finally {53 serverSocket=null;54 }55 return isserverRunning;56 }57 58 public static void startEmulator() throws IOException, InterruptedException59 {60 Runtime.getRuntime().exec(System.getProperty("user.dir")+"\\src\\main\\java\\Emulator.bat");61 Thread.sleep(8000);62 }63 64 public static AndroidDriver<AndroidElement> Capability(String appPackage, String appActivity,String deviceName,String chromedriverExecutable) throws IOException, InterruptedException {65 FileReader fis = new FileReader(System.getProperty("user.dir")+"//src//main//java//global.properties");66 Properties Pro = new Properties();67 Pro.load(fis);68 appPackage = Pro.getProperty("appPakcage");69 appActivity = Pro.getProperty("appActivity");70 deviceName = Pro.getProperty("deviceName");71 if(deviceName.contains("Shashank"))72 {73 startEmulator();74 }75 76 chromedriverExecutable = Pro.getProperty("chromedriverExecutable");77 78 //DesiredCapabilities cap = new DesiredCapabilities();79 //cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Shashank"); 80 //cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");81 //cap.setCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE, "Training\\SDET\\Appium\\chromedriver_win32\\chromedriver.exe");82 //cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);83 //cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.androidsample.generalstore"); 84 //cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "com.androidsample.generalstore.SplashActivity");85 //AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap);86 //return driver;87 DesiredCapabilities cap = new DesiredCapabilities();88 cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Shashank"); 89 cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");90 cap.setCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE, "C:\\SVN\\mobile\\WebApp\\driver.chromedriver.exe");91 cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);92 cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "org.khanacademy.android"); 93 cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "org.khanacademy.android.ui.library.MainActivity");94 AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap);95 return driver;96 }97}...

Full Screen

Full Screen

AndroidDriverManager.java

Source:AndroidDriverManager.java Github

copy

Full Screen

...34import io.appium.java_client.AppiumDriver;35import io.appium.java_client.MobileElement;36import io.appium.java_client.android.AndroidDriver;37import io.appium.java_client.remote.AndroidMobileCapabilityType;38import io.appium.java_client.remote.AutomationName;39import io.appium.java_client.remote.MobilePlatform;40import java.io.File;41import java.net.MalformedURLException;42import java.net.URL;43import org.apache.logging.log4j.LogManager;44import org.apache.logging.log4j.Logger;45import org.openqa.selenium.remote.DesiredCapabilities;46public class AndroidDriverManager implements IDriver {47 private static final Logger logger = LogManager.getLogger(AndroidDriverManager.class);48 private AppiumDriver<MobileElement> driver;49 @Override50 public AppiumDriver<MobileElement> createInstance(String udid, String platformVersion) {51 try {52 Configuration configuration = ConfigurationManager.getConfiguration();53 DesiredCapabilities capabilities = new DesiredCapabilities();54 capabilities.setCapability(UDID, udid);55 capabilities.setCapability(PLATFORM_VERSION, platformVersion);56 capabilities.setCapability(DEVICE_NAME, "Android Emulator");57 capabilities.setCapability(PLATFORM_NAME, MobilePlatform.ANDROID);58 capabilities.setCapability(AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);59 if (Boolean.TRUE.equals(configuration.installApp())) {60 capabilities.setCapability(APP, new File(configuration.androidAppPath()).getAbsolutePath());61 } else {62 capabilities63 .setCapability(AndroidMobileCapabilityType.APP_PACKAGE, configuration.androidAppPackage());64 capabilities65 .setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, configuration.androidAppActivity());66 }67 driver = new AndroidDriver<>(new URL(gridUrl()), capabilities);68 } catch (MalformedURLException e) {69 logger.error("Failed to initiate the tests for the Android device", e);70 }71 return driver;72 }...

Full Screen

Full Screen

IOSDriverManager.java

Source:IOSDriverManager.java Github

copy

Full Screen

...33import com.eliasnogueira.driver.IDriver;34import io.appium.java_client.AppiumDriver;35import io.appium.java_client.MobileElement;36import io.appium.java_client.ios.IOSDriver;37import io.appium.java_client.remote.AutomationName;38import io.appium.java_client.remote.IOSMobileCapabilityType;39import io.appium.java_client.remote.MobilePlatform;40import java.io.File;41import java.net.MalformedURLException;42import java.net.URL;43import org.apache.logging.log4j.LogManager;44import org.apache.logging.log4j.Logger;45import org.openqa.selenium.remote.DesiredCapabilities;46public class IOSDriverManager implements IDriver {47 private static final Logger logger = LogManager.getLogger(IOSDriverManager.class);48 private AppiumDriver<MobileElement> driver;49 @Override50 public AppiumDriver<MobileElement> createInstance(String udid, String platformVersion) {51 try {52 Configuration configuration = ConfigurationManager.getConfiguration();53 DesiredCapabilities capabilities = new DesiredCapabilities();54 capabilities.setCapability(UDID, udid);55 capabilities.setCapability(PLATFORM_VERSION, platformVersion);56 capabilities.setCapability(DEVICE_NAME, "iPhone Simulator");57 capabilities.setCapability(PLATFORM_NAME, MobilePlatform.IOS);58 capabilities.setCapability(AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST);59 if (Boolean.TRUE.equals(configuration.installApp())) {60 capabilities.setCapability(APP, new File(configuration.iosAppPath()).getAbsolutePath());61 } else {62 capabilities.setCapability(IOSMobileCapabilityType.APP_NAME, configuration.iosAppName());63 }64 driver = new IOSDriver<>(new URL(gridUrl()), capabilities);65 } catch (MalformedURLException e) {66 logger.error("Failed to initiate the tests for the IOS device", e);67 }68 return driver;69 }70}...

Full Screen

Full Screen

Capabilities.java

Source:Capabilities.java Github

copy

Full Screen

...11import io.appium.java_client.AppiumDriver;12import io.appium.java_client.android.AndroidDriver;13import io.appium.java_client.android.AndroidElement;14import io.appium.java_client.remote.AndroidMobileCapabilityType;15import io.appium.java_client.remote.AutomationName;16import io.appium.java_client.remote.MobileCapabilityType;17import io.appium.java_client.service.local.AppiumDriverLocalService;18import io.appium.java_client.service.local.AppiumServiceBuilder;19public class Capabilities {20 public static String apppackage,appactivity,devicename,platformname;21 22 public AppiumDriverLocalService service;23 public AppiumDriverLocalService startServer()24 {25 boolean flag = checkifserverisRunning(4723);26 if(!flag)27 {28 service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().usingDriverExecutable(new File("C:\\Program Files\\nodejs\\node.exe"))29 .withAppiumJS(new File("C://Users//user//AppData//Roaming//npm//node_modules//appium//build//lib//main.js"))30 .withIPAddress("127.0.0.1").usingPort(4723));31 service.start();32 33 }34 return service;35 }36 37 public static boolean checkifserverisRunning(int port)38 {39 boolean isServerRunning=false;40 ServerSocket serversocket;41 try{42 serversocket = new ServerSocket(port);43 serversocket.close();44 }45 catch(IOException e)46 {47 isServerRunning = true;48 }49 finally {50 serversocket=null;51 }52 return isServerRunning;53 }54 55 public static void StartEmulator() throws IOException, InterruptedException56 {57 Runtime.getRuntime().exec(System.getProperty("user.dir")+"\\src\\main\\resources\\emulator.bat");58 Thread.sleep(15000);59 }60 public static AndroidDriver<AndroidElement> capability() throws IOException, InterruptedException {61 // TODO Auto-generated method stub62 FileReader fis = new FileReader(System.getProperty("user.dir")+"\\src\\main\\java\\Global.properties");63 Properties pro = new Properties();64 pro.load(fis);65 apppackage = pro.getProperty("apppackage");66 appactivity = pro.getProperty("appactivity");67 devicename = pro.getProperty("devicename");68 platformname = pro.getProperty("platformname");69if(devicename.contains("amol"))70{71 StartEmulator();72 Thread.sleep(15000);73 74}75 DesiredCapabilities cap = new DesiredCapabilities();76 cap.setCapability(MobileCapabilityType.DEVICE_NAME,devicename);77 cap.setCapability(MobileCapabilityType.PLATFORM_NAME,platformname);78 cap.setCapability(MobileCapabilityType.NO_RESET, true);79 cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);80 cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,apppackage);81 cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,appactivity);82 cap.setCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE,"C:\\Users\\user\\Downloads\\chromedriver_win32\\chromedriver.exe");83 84 AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap);85 //I don't want to write this capability again and again for all the classes so I want to keep this common and import this in all the classes86 return driver;87 }88}...

Full Screen

Full Screen

EETest.java

Source:EETest.java Github

copy

Full Screen

1import io.appium.java_client.AppiumDriver;2import io.appium.java_client.MobileElement;3import io.appium.java_client.android.AndroidDriver;4import io.appium.java_client.remote.AndroidMobileCapabilityType;5import io.appium.java_client.remote.AutomationName;6import io.appium.java_client.remote.MobileCapabilityType;7import org.openqa.selenium.By;8import org.openqa.selenium.remote.DesiredCapabilities;9import org.testng.annotations.Test;10import java.net.MalformedURLException;11import java.net.URL;12/**13 * Created by equalexperts on 09/02/18.14 */15public class EETest {16 public AppiumDriver<MobileElement> driver;17 @Test18 public void test() throws MalformedURLException, InterruptedException {19 DesiredCapabilities capabilities = new DesiredCapabilities();20 //capabilities.setPlatform(Platform.ANDROID);21 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"emulator-5554");22 capabilities.setCapability(MobileCapabilityType.PLATFORM,"Android");23 capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"7.1.1");24 capabilities.setCapability(MobileCapabilityType.APP,"/Users/equalexperts/work/wordpress.apk");25 capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,"org.wordpress.android");26 capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,"org.wordpress.android.ui.accounts.SignInActivity");27 capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);28 driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);29// driver.findElement(By.id("org.wordpress.android:id/nux_username")).sendKeys("vodqa@gmail.com"30 driver.findElement(By.className("android.widget.EditText")).sendKeys("vodqa@gmail.com");31 driver.findElement(By.id("org.wordpress.android:id/nux_sign_in_button")).click();32// driver.findElement(By.name("Next")).click();33 Thread.sleep(4000);34 driver.quit();35 }36}...

Full Screen

Full Screen

AppiumDriverType.java

Source:AppiumDriverType.java Github

copy

Full Screen

2import io.appium.java_client.AppiumDriver;3import io.appium.java_client.android.Activity;4import io.appium.java_client.android.AndroidDriver;5import io.appium.java_client.remote.AndroidMobileCapabilityType;6import io.appium.java_client.remote.AutomationName;7import io.appium.java_client.remote.MobileCapabilityType;8import org.openqa.selenium.Platform;9import org.openqa.selenium.remote.DesiredCapabilities;10import java.net.URL;11public enum AppiumDriverType implements DriverSetup {12 ANDROID {13 public AppiumDriverType createAppiumObject(URL appiumServerLocation, DesiredCapabilities desiredCapabilities) {14 capabilities = desiredCapabilities;15 serverLocation = appiumServerLocation;16 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, Platform.ANDROID);17 capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.APPIUM);18 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Device");19 if (ENABLE_DEBUG_MODE) {20 capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "3600");21 }22 return this;23 }24 public AppiumDriver getAppiumDriver() {25 return new AndroidDriver(serverLocation, capabilities);26 }27 };28 private static final boolean ENABLE_DEBUG_MODE = Boolean.getBoolean("enableDebugMode");29 DesiredCapabilities capabilities;30 URL serverLocation;31 public AppiumDriverType setActivity(Activity activity) {...

Full Screen

Full Screen

DriverManager.java

Source:DriverManager.java Github

copy

Full Screen

1package managers;2import java.net.MalformedURLException;3import java.net.URL;4import java.util.concurrent.TimeUnit;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.remote.CapabilityType;7import org.openqa.selenium.remote.DesiredCapabilities;8import io.appium.java_client.AppiumDriver;9import io.appium.java_client.HasSettings;10import io.appium.java_client.MobileElement;11import io.appium.java_client.Setting;12import io.appium.java_client.remote.MobileCapabilityType;13public class DriverManager {14 private WebDriver driver;15 public WebDriver getDriver() {16 driver = createDriver();17 return driver;18 }19 private WebDriver createDriver() {20 DesiredCapabilities caps = new DesiredCapabilities();21 /*22 * Local Emulator settings23 */24 caps.setCapability("platformName", "Android");25 caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11");26 caps.setCapability(MobileCapabilityType.UDID, "emulator-5554");27 caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);28 caps.setCapability("automationName", "UiAutomator2");29 caps.setCapability("waitForIdleTimeout", 200);30 //caps.setCapability("automationName", "UiAutomator2");31 caps.setCapability("appPackage", "com.stanbicibtc.mobile");32 caps.setCapability("appActivity", "com.stanbicibtc.mobile.MainActivity");33 34 URL url = null; 35 try {36 url = new URL("http://127.0.0.1:4723/wd/hub");37 } catch (MalformedURLException e) {38 e.printStackTrace();39 }40 driver = new AppiumDriver<MobileElement>(url, caps);41 driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);42 return driver;43 }44 public void closeDriver() {45 if(driver == null) {46 // driver.close();47 //driver.quit();48 }49 }50}...

Full Screen

Full Screen

BaseTest.java

Source:BaseTest.java Github

copy

Full Screen

1package tests;2import io.appium.java_client.AppiumDriver;3import io.appium.java_client.android.AndroidDriver;4import io.appium.java_client.remote.AndroidMobileCapabilityType;5import io.appium.java_client.remote.AutomationName;6import io.appium.java_client.remote.MobileCapabilityType;7import org.openqa.selenium.remote.DesiredCapabilities;8import java.net.MalformedURLException;9import java.net.URL;10/**11 * Created by equalexperts on 04/02/18.12 */13public class BaseTest {14 public AppiumDriver driver;15 public BaseTest() {16 DesiredCapabilities capabilities = new DesiredCapabilities();17 //capabilities.setPlatform(Platform.ANDROID);18 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"emulator-5554");19 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"7.1.1");20 capabilities.setCapability(MobileCapabilityType.APP,"/Users/equalexperts/work/wordpress.apk");21 capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,"org.wordpress.android");22 capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,"org.wordpress.android.ui.WPLaunchActivity");23 capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);24 try {25 driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);26 }catch (MalformedURLException e){27 e.fillInStackTrace();28 }29 }30}...

Full Screen

Full Screen

AutomationName

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities capabilities = new DesiredCapabilities();2capabilities.setCapability("automationName", AutomationName.IOS_XCUI_TEST);3DesiredCapabilities capabilities = new DesiredCapabilities();4capabilities.setCapability("automationName", AutomationName.SELENDROID);5DesiredCapabilities capabilities = new DesiredCapabilities();6capabilities.setCapability("automationName", AutomationName.APPIUM);7DesiredCapabilities capabilities = new DesiredCapabilities();8capabilities.setCapability("automationName", AutomationName.WINAPPIUM);9DesiredCapabilities capabilities = new DesiredCapabilities();10capabilities.setCapability("automationName", AutomationName.WINAPPIUM);11DesiredCapabilities capabilities = new DesiredCapabilities();12capabilities.setCapability("automationName", AutomationName.WINAPPIUM);13DesiredCapabilities capabilities = new DesiredCapabilities();14capabilities.setCapability("automationName", AutomationName.WINAPPIUM);15DesiredCapabilities capabilities = new DesiredCapabilities();16capabilities.setCapability("automationName", AutomationName.WINAPPIUM);

Full Screen

Full Screen

AutomationName

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.remote.AutomationName;2driver.setCapability("automationName", AutomationName.IOS_XCUI_TEST);3driver.setCapability('automationName', 'XCUITest');4driver.setCapability('automationName', 'XCUITest')5driver.setCapability(:automationName, 'XCUITest')6driver.set_capability("automationName", "XCUITest")7driver.setCapability("automationName", AutomationName.IOS_XCUI_TEST);8driver.setCapability("automationName", AutomationName.IOS_XCUI_TEST);9driver.SetCapability("automationName", appium.AutomationNameIosXcuiTest)10$driver->setCapability("automationName", Facebook\WebDriver\Remote\WebDriverCapabilityType::IOS_XCUI_TEST);11driver.setCapability('automationName', 'XCUITest')12$driver.SetCapability("automationName", [OpenQA.Selenium.Appium.Enums]::IOS_XCUI_TEST)13$driver.SetCapability("automationName", [OpenQA.Selenium.Appium.Enums]::IOS_XCUI_TEST)14driver.set_capability("automationName", appium::AutomationName::IOS_XCUI_TEST);15driver.setCapability(:automationName

Full Screen

Full Screen

AutomationName

Using AI Code Generation

copy

Full Screen

1package appium.java;2import java.net.MalformedURLException;3import java.net.URL;4import org.openqa.selenium.remote.DesiredCapabilities;5import io.appium.java_client.android.AndroidDriver;6import io.appium.java_client.remote.AutomationName;7import io.appium.java_client.remote.MobileCapabilityType;8public class AppiumJava {9public static void main(String[] args) throws MalformedURLException, InterruptedException {10DesiredCapabilities caps = new DesiredCapabilities();11caps.setCapability("deviceName", "Pixel 3 API 29");12caps.setCapability("platformName", "Android");13caps.setCapability("appPackage", "com.androidsample.generalstore");14caps.setCapability("appActivity", ".SplashActivity");15caps.setCapability("noReset", "true");16caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful