How to use ensurePlatformName method of io.appium.java_client.AppiumDriver class

Best io.appium code snippet using io.appium.java_client.AppiumDriver.ensurePlatformName

AppiumDriver.java

Source:AppiumDriver.java Github

copy

Full Screen

...114 * @param defaultName a {@link MobileCapabilityType#PLATFORM_NAME} value which has115 * to be set up116 * @return {@link Capabilities} with changed platform name value or the original capabilities117 */118 protected static Capabilities ensurePlatformName(119 Capabilities originalCapabilities, String defaultName) {120 String currentName = (String) originalCapabilities.getCapability(PLATFORM_NAME);121 return isBlank(currentName)122 ? originalCapabilities.merge(new ImmutableCapabilities(PLATFORM_NAME, defaultName))123 : originalCapabilities;124 }125 /**126 * Changes automation name if it is not set and returns merged capabilities.127 *128 * @param originalCapabilities the given {@link Capabilities}.129 * @param defaultName a {@link MobileCapabilityType#AUTOMATION_NAME} value which has130 * to be set up131 * @return {@link Capabilities} with changed mobile automation name value or the original capabilities132 */133 protected static Capabilities ensureAutomationName(134 Capabilities originalCapabilities, String defaultName) {135 String currentAutomationName = CapabilityHelpers.getCapability(136 originalCapabilities, AUTOMATION_NAME, String.class);137 if (isBlank(currentAutomationName)) {138 String capabilityName = originalCapabilities.getCapabilityNames()139 .contains(AUTOMATION_NAME) ? AUTOMATION_NAME : APPIUM_PREFIX + AUTOMATION_NAME;140 return originalCapabilities.merge(new ImmutableCapabilities(capabilityName, defaultName));141 }142 return originalCapabilities;143 }144 /**145 * Changes platform and automation names if they are not set146 * and returns merged capabilities.147 *148 * @param originalCapabilities the given {@link Capabilities}.149 * @param defaultPlatformName a {@link MobileCapabilityType#PLATFORM_NAME} value which has150 * to be set up151 * @param defaultAutomationName The default automation name to set up for this class152 * @return {@link Capabilities} with changed platform/automation name value or the original capabilities153 */154 protected static Capabilities ensurePlatformAndAutomationNames(155 Capabilities originalCapabilities, String defaultPlatformName, String defaultAutomationName) {156 Capabilities capsWithPlatformFixed = ensurePlatformName(originalCapabilities, defaultPlatformName);157 return ensureAutomationName(capsWithPlatformFixed, defaultAutomationName);158 }159 @Override160 public ExecuteMethod getExecuteMethod() {161 return executeMethod;162 }163 /**164 * This method is used to get build version status of running Appium server.165 *166 * @return map containing version details167 */168 public Map<String, Object> getStatus() {169 //noinspection unchecked170 return (Map<String, Object>) execute(DriverCommand.STATUS).getValue();...

Full Screen

Full Screen

AndroidDriver.java

Source:AndroidDriver.java Github

copy

Full Screen

...94 * commands may be specified there.95 * @param capabilities take a look at {@link Capabilities}96 */97 public AndroidDriver(HttpCommandExecutor executor, Capabilities capabilities) {98 super(executor, ensurePlatformName(capabilities, ANDROID_PLATFORM));99 }100 /**101 * Creates a new instance based on Appium server URL and {@code capabilities}.102 *103 * @param remoteAddress is the address of remotely/locally started Appium server104 * @param capabilities take a look at {@link Capabilities}105 */106 public AndroidDriver(URL remoteAddress, Capabilities capabilities) {107 super(remoteAddress, ensurePlatformName(capabilities, ANDROID_PLATFORM));108 }109 /**110 * Creates a new instance based on Appium server URL, HTTP client factory and {@code capabilities}.111 *112 * @param remoteAddress is the address of remotely/locally started Appium server113 * @param httpClientFactory take a look at {@link HttpClient.Factory}114 * @param capabilities take a look at {@link Capabilities}115 */116 public AndroidDriver(117 URL remoteAddress, HttpClient.Factory httpClientFactory, Capabilities capabilities) {118 super(remoteAddress, httpClientFactory, ensurePlatformName(capabilities, ANDROID_PLATFORM));119 }120 /**121 * Creates a new instance based on Appium driver local service and {@code capabilities}.122 *123 * @param service take a look at {@link AppiumDriverLocalService}124 * @param capabilities take a look at {@link Capabilities}125 */126 public AndroidDriver(AppiumDriverLocalService service, Capabilities capabilities) {127 super(service, ensurePlatformName(capabilities, ANDROID_PLATFORM));128 }129 /**130 * Creates a new instance based on Appium driver local service, HTTP client factory and {@code capabilities}.131 *132 * @param service take a look at {@link AppiumDriverLocalService}133 * @param httpClientFactory take a look at {@link HttpClient.Factory}134 * @param capabilities take a look at {@link Capabilities}135 */136 public AndroidDriver(137 AppiumDriverLocalService service, HttpClient.Factory httpClientFactory, Capabilities capabilities) {138 super(service, httpClientFactory, ensurePlatformName(capabilities, ANDROID_PLATFORM));139 }140 /**141 * Creates a new instance based on Appium service builder and {@code capabilities}.142 *143 * @param builder take a look at {@link AppiumServiceBuilder}144 * @param capabilities take a look at {@link Capabilities}145 */146 public AndroidDriver(AppiumServiceBuilder builder, Capabilities capabilities) {147 super(builder, ensurePlatformName(capabilities, ANDROID_PLATFORM));148 }149 /**150 * Creates a new instance based on Appium service builder, HTTP client factory and {@code capabilities}.151 *152 * @param builder take a look at {@link AppiumServiceBuilder}153 * @param httpClientFactory take a look at {@link HttpClient.Factory}154 * @param capabilities take a look at {@link Capabilities}155 */156 public AndroidDriver(AppiumServiceBuilder builder, HttpClient.Factory httpClientFactory,157 Capabilities capabilities) {158 super(builder, httpClientFactory, ensurePlatformName(capabilities, ANDROID_PLATFORM));159 }160 /**161 * Creates a new instance based on HTTP client factory and {@code capabilities}.162 *163 * @param httpClientFactory take a look at {@link HttpClient.Factory}164 * @param capabilities take a look at {@link Capabilities}165 */166 public AndroidDriver(HttpClient.Factory httpClientFactory, Capabilities capabilities) {167 super(httpClientFactory, ensurePlatformName(capabilities, ANDROID_PLATFORM));168 }169 /**170 * Creates a new instance based on {@code capabilities}.171 *172 * @param capabilities take a look at {@link Capabilities}173 */174 public AndroidDriver(Capabilities capabilities) {175 super(ensurePlatformName(capabilities, ANDROID_PLATFORM));176 }177 /**178 * Get test-coverage data.179 *180 * @param intent intent to broadcast.181 * @param path path to .ec file.182 */183 public void endTestCoverage(String intent, String path) {184 CommandExecutionHelper.execute(this, endTestCoverageCommand(intent, path));185 }186 /**187 * Open the notification shade, on Android devices.188 */189 public void openNotifications() {...

Full Screen

Full Screen

IOSDriver.java

Source:IOSDriver.java Github

copy

Full Screen

...83 * commands may be specified there.84 * @param capabilities take a look at {@link Capabilities}85 */86 public IOSDriver(HttpCommandExecutor executor, Capabilities capabilities) {87 super(executor, ensurePlatformName(capabilities, PLATFORM_NAME));88 }89 /**90 * Creates a new instance based on Appium server URL and {@code capabilities}.91 *92 * @param remoteAddress is the address of remotely/locally started Appium server93 * @param capabilities take a look at {@link Capabilities}94 */95 public IOSDriver(URL remoteAddress, Capabilities capabilities) {96 super(remoteAddress, ensurePlatformName(capabilities, PLATFORM_NAME));97 }98 /**99 * Creates a new instance based on Appium server URL, HTTP client factory and {@code capabilities}.100 *101 * @param remoteAddress is the address of remotely/locally started Appium server102 * @param httpClientFactory take a look at {@link HttpClient.Factory}103 * @param capabilities take a look at {@link Capabilities}104 */105 public IOSDriver(URL remoteAddress, HttpClient.Factory httpClientFactory,106 Capabilities capabilities) {107 super(remoteAddress, httpClientFactory, ensurePlatformName(capabilities, PLATFORM_NAME));108 }109 /**110 * Creates a new instance based on Appium driver local service and {@code capabilities}.111 *112 * @param service take a look at {@link AppiumDriverLocalService}113 * @param capabilities take a look at {@link Capabilities}114 */115 public IOSDriver(AppiumDriverLocalService service, Capabilities capabilities) {116 super(service, ensurePlatformName(capabilities, PLATFORM_NAME));117 }118 /**119 * Creates a new instance based on Appium driver local service, HTTP client factory and {@code capabilities}.120 *121 * @param service take a look at {@link AppiumDriverLocalService}122 * @param httpClientFactory take a look at {@link HttpClient.Factory}123 * @param capabilities take a look at {@link Capabilities}124 */125 public IOSDriver(AppiumDriverLocalService service, HttpClient.Factory httpClientFactory,126 Capabilities capabilities) {127 super(service, httpClientFactory, ensurePlatformName(capabilities, PLATFORM_NAME));128 }129 /**130 * Creates a new instance based on Appium service builder and {@code capabilities}.131 *132 * @param builder take a look at {@link AppiumServiceBuilder}133 * @param capabilities take a look at {@link Capabilities}134 */135 public IOSDriver(AppiumServiceBuilder builder, Capabilities capabilities) {136 super(builder, ensurePlatformName(capabilities, PLATFORM_NAME));137 }138 /**139 * Creates a new instance based on Appium service builder, HTTP client factory and {@code capabilities}.140 *141 * @param builder take a look at {@link AppiumServiceBuilder}142 * @param httpClientFactory take a look at {@link HttpClient.Factory}143 * @param capabilities take a look at {@link Capabilities}144 */145 public IOSDriver(AppiumServiceBuilder builder, HttpClient.Factory httpClientFactory,146 Capabilities capabilities) {147 super(builder, httpClientFactory, ensurePlatformName(capabilities, PLATFORM_NAME));148 }149 /**150 * Creates a new instance based on HTTP client factory and {@code capabilities}.151 *152 * @param httpClientFactory take a look at {@link HttpClient.Factory}153 * @param capabilities take a look at {@link Capabilities}154 */155 public IOSDriver(HttpClient.Factory httpClientFactory, Capabilities capabilities) {156 super(httpClientFactory, ensurePlatformName(capabilities, PLATFORM_NAME));157 }158 /**159 * Creates a new instance based on {@code capabilities}.160 *161 * @param capabilities take a look at {@link Capabilities}162 */163 public IOSDriver(Capabilities capabilities) {164 super(ensurePlatformName(capabilities, PLATFORM_NAME));165 }166 @Override public TargetLocator switchTo() {167 return new InnerTargetLocator();168 }169 @SuppressWarnings("unchecked")170 @Override171 public IOSBatteryInfo getBatteryInfo() {172 return new IOSBatteryInfo((Map<String, Object>) execute(EXECUTE_SCRIPT, ImmutableMap.of(173 "script", "mobile: batteryInfo", "args", Collections.emptyList())).getValue());174 }175 private class InnerTargetLocator extends RemoteTargetLocator {176 @Override public Alert alert() {177 return new IOSAlert(super.alert());178 }...

Full Screen

Full Screen

ensurePlatformName

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.AppiumDriver;2import io.appium.java_client.android.AndroidDriver;3import io.appium.java_client.android.AndroidElement;4import io.appium.java_client.ios.IOSDriver;5import io.appium.java_client.ios.IOSElement;6import org.openqa.selenium.remote.DesiredCapabilities;7import org.testng.annotations.Test;8import java.net.MalformedURLException;9import java.net.URL;10import java.util.concurrent.TimeUnit;11public class AppiumTest {12public void appiumTest() throws MalformedURLException {13DesiredCapabilities capabilities = new DesiredCapabilities();14capabilities.setCapability("platformName", "Android");15capabilities.setCapability("platformVersion", "6.0.1");16capabilities.setCapability("deviceName", "Android Emulator");17capabilities.setCapability("app", "path/to/your.apk");18capabilities.setCapability("appPackage", "com.example.android.contactmanager");19capabilities.setCapability("appActivity", ".ContactManager");

Full Screen

Full Screen

ensurePlatformName

Using AI Code Generation

copy

Full Screen

1package appium;2import java.net.MalformedURLException;3import java.net.URL;4import java.util.concurrent.TimeUnit;5import org.openqa.selenium.remote.DesiredCapabilities;6import org.testng.annotations.AfterTest;7import org.testng.annotations.BeforeTest;8import org.testng.annotations.Test;9import io.appium.java_client.AppiumDriver;10import io.appium.java_client.MobileElement;11public class EnsurePlatformName {12 AppiumDriver<MobileElement> driver = null;13 public void setup() throws MalformedURLException {14 DesiredCapabilities caps = new DesiredCapabilities();15 caps.setCapability("deviceName", "Pixel 4 Emulator");16 caps.setCapability("platformName", "Android");17 caps.setCapability("appPackage", "com.android.calculator2");18 caps.setCapability("appActivity", ".Calculator");19 caps.setCapability("noReset", true);

Full Screen

Full Screen

ensurePlatformName

Using AI Code Generation

copy

Full Screen

1AppiumDriver driver = new AndroidDriver();2driver.ensurePlatformName("Android");3AppiumDriver driver = new IOSDriver();4driver.ensurePlatformName("iOS");5AppiumDriver driver = new RemoteWebDriver();6driver.ensurePlatformName("Android");7AppiumDriver driver = new RemoteWebDriver();8driver.ensurePlatformName("iOS");9AppiumDriver driver = new RemoteWebDriver();10driver.ensurePlatformName("Android");11AppiumDriver driver = new RemoteWebDriver();12driver.ensurePlatformName("iOS");13AppiumDriver driver = new RemoteWebDriver();14driver.ensurePlatformName("Android");15AppiumDriver driver = new RemoteWebDriver();16driver.ensurePlatformName("iOS");17AppiumDriver driver = new RemoteWebDriver();18driver.ensurePlatformName("Android");19AppiumDriver driver = new RemoteWebDriver();20driver.ensurePlatformName("iOS");21AppiumDriver driver = new RemoteWebDriver();22driver.ensurePlatformName("Android");23AppiumDriver driver = new RemoteWebDriver();24driver.ensurePlatformName("iOS");

Full Screen

Full Screen

ensurePlatformName

Using AI Code Generation

copy

Full Screen

1AppiumDriver driver = new AppiumDriver();2String platformName = driver.ensurePlatformName();3AppiumDriver driver = new AppiumDriver();4String automationName = driver.ensureAutomationName();5AppiumDriver driver = new AppiumDriver();6String platformVersion = driver.ensurePlatformVersion();7AppiumDriver driver = new AppiumDriver();8String deviceName = driver.ensureDeviceName();9AppiumDriver driver = new AppiumDriver();10String app = driver.ensureApp();11AppiumDriver driver = new AppiumDriver();12String browserName = driver.ensureBrowserName();13AppiumDriver driver = new AppiumDriver();14String bundleId = driver.ensureBundleId();15AppiumDriver driver = new AppiumDriver();16String automationInsghts = driver.ensureAutomationInsghts();17AppiumDriver driver = new AppiumDriver();18String eventTimings = driver.ensureEventTimings();19AppiumDriver driver = new AppiumDriver();20String language = driver.ensureLanguage();21AppiumDriver driver = new AppiumDriver();22String locale = driver.ensureLocale();

Full Screen

Full Screen

ensurePlatformName

Using AI Code Generation

copy

Full Screen

1AppiumDriver driver = new AppiumDriver();2driver.ensurePlatformName("Android");3AppiumDriver driver = new AppiumDriver();4driver.ensurePlatformName("iOS");5var driver = new AppiumDriver();6driver.ensurePlatformName("Android");7var driver = new AppiumDriver();8driver.ensurePlatformName("iOS");9AppiumDriver driver = new AppiumDriver();10driver.ensurePlatformName("Android");11AppiumDriver driver = new AppiumDriver();12driver.ensurePlatformName("iOS");13var driver = new AppiumDriver();14driver.ensurePlatformName("Android");15var driver = new AppiumDriver();16driver.ensurePlatformName("iOS");17AppiumDriver driver = new AppiumDriver();18driver.ensurePlatformName("Android");

Full Screen

Full Screen

ensurePlatformName

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.AppiumDriver;2import org.openqa.selenium.remote.DesiredCapabilities;3import org.openqa.selenium.Platform;4import java.net.URL;5public class AppiumDriverExample {6 public static void main(String[] args) throws Exception {7 DesiredCapabilities capabilities = new DesiredCapabilities();8 capabilities.setCapability("platformName", "Android");

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