How to use WindowsOptions class of io.appium.java_client.windows.options package

Best io.appium code snippet using io.appium.java_client.windows.options.WindowsOptions

OptionsBuildingTest.java

Source:OptionsBuildingTest.java Github

copy

Full Screen

...31import io.appium.java_client.remote.AutomationName;32import io.appium.java_client.safari.options.SafariOptions;33import io.appium.java_client.safari.options.WebrtcData;34import io.appium.java_client.windows.options.PowerShellData;35import io.appium.java_client.windows.options.WindowsOptions;36import org.junit.Test;37import org.openqa.selenium.Platform;38import java.net.MalformedURLException;39import java.net.URL;40import java.time.Duration;41import static org.junit.Assert.assertEquals;42import static org.junit.Assert.assertFalse;43import static org.junit.Assert.assertNotNull;44import static org.junit.Assert.assertTrue;45@SuppressWarnings("ConstantConditions")46public class OptionsBuildingTest {47 @Test48 public void canBuildXcuiTestOptions() throws MalformedURLException {49 XCUITestOptions options = new XCUITestOptions();50 assertEquals(Platform.IOS, options.getPlatformName());51 assertEquals(AutomationName.IOS_XCUI_TEST, options.getAutomationName().orElse(null));52 options.setNewCommandTimeout(Duration.ofSeconds(10))53 .noReset()54 .setWdaBaseUrl("http://localhost:8000")55 .setPermissions(new Permissions()56 .withAppPermissions("com.apple.MobileSafari",57 ImmutableMap.of("calendar", "YES")))58 .setSafariSocketChunkSize(10)59 .setCommandTimeouts(new CommandTimeouts()60 .withCommandTimeout("yolo", Duration.ofSeconds(1)));61 assertEquals(Duration.ofSeconds(10), options.getNewCommandTimeout().orElse(null));62 assertEquals(new URL("http://localhost:8000"), options.getWdaBaseUrl().orElse(null));63 assertNotNull(options.getPermissions()64 .map((v) -> v.getAppPermissions("com.apple.MobileSafari"))65 .orElse(null));66 assertEquals(10L, (long) options.getSafariSocketChunkSize().orElse(0));67 assertEquals(1L, options.getCommandTimeouts().orElse(null).left()68 .getCommandTimeout("yolo").orElse(null).getSeconds());69 }70 @Test71 public void canBuildUiAutomator2Options() throws MalformedURLException {72 UiAutomator2Options options = new UiAutomator2Options();73 assertEquals(Platform.ANDROID, options.getPlatformName());74 assertEquals(AutomationName.ANDROID_UIAUTOMATOR2, options.getAutomationName().orElse(null));75 options.setNewCommandTimeout(Duration.ofSeconds(10))76 .noReset()77 .setAdbExecTimeout(Duration.ofSeconds(3))78 .suppressKillServer()79 .setMjpegScreenshotUrl(new URL("http://yolo.com"))80 .setKeystoreConfig(new KeystoreConfig("path", "password", "keyAlias", "keyPassword"));81 assertEquals(Duration.ofSeconds(10), options.getNewCommandTimeout().orElse(null));82 assertEquals(Duration.ofSeconds(3), options.getAdbExecTimeout().orElse(null));83 assertEquals(new URL("http://yolo.com"), options.getMjpegScreenshotUrl().orElse(null));84 assertEquals("path", options.getKeystoreConfig().orElse(null).getPath());85 assertEquals("keyAlias", options.getKeystoreConfig().orElse(null).getKeyAlias());86 assertTrue(options.doesSuppressKillServer().orElse(false));87 }88 @Test89 public void canBuildEspressoOptions() {90 EspressoOptions options = new EspressoOptions();91 assertEquals(Platform.ANDROID, options.getPlatformName());92 assertEquals(AutomationName.ESPRESSO, options.getAutomationName().orElse(null));93 options.setNewCommandTimeout(Duration.ofSeconds(10))94 .forceEspressoRebuild()95 .setAppLocale(new AppLocale()96 .withCountry("CN")97 .withLanguage("zh")98 .withVariant("hans"))99 .setEspressoBuildConfig(new EspressoBuildConfig()100 .withAdditionalAppDependencies(ImmutableList.of(101 "com.dep1:1.2.3",102 "com.dep2:1.2.3"103 ))104 );105 assertEquals(Duration.ofSeconds(10), options.getNewCommandTimeout().orElse(null));106 assertEquals("CN", options.getAppLocale().orElse(null).getCountry().orElse(null));107 assertEquals(2, options.getEspressoBuildConfig().orElse(null)108 .left().getAdditionalAppDependencies().orElse(null).size());109 assertTrue(options.doesForceEspressoRebuild().orElse(false));110 }111 @Test112 public void canBuildWindowsOptions() {113 WindowsOptions options = new WindowsOptions();114 assertEquals(Platform.WINDOWS, options.getPlatformName());115 assertEquals(AutomationName.WINDOWS, options.getAutomationName().orElse(null));116 options.setNewCommandTimeout(Duration.ofSeconds(10))117 .setPrerun(new PowerShellData().withScript("yolo prescript"))118 .setPostrun(new PowerShellData().withCommand("yolo command"));119 assertEquals(Duration.ofSeconds(10), options.getNewCommandTimeout().orElse(null));120 assertEquals("yolo prescript", options.getPrerun().orElse(null).getScript().orElse(null));121 assertEquals("yolo command", options.getPostrun().orElse(null).getCommand().orElse(null));122 }123 @Test124 public void canBuildMac2Options() {125 Mac2Options options = new Mac2Options();126 assertEquals(Platform.MAC, options.getPlatformName());127 assertEquals(AutomationName.MAC2, options.getAutomationName().orElse(null));...

Full Screen

Full Screen

WindowsOptions.java

Source:WindowsOptions.java Github

copy

Full Screen

...25import java.util.Optional;26/**27 * https://github.com/appium/appium-windows-driver#usage28 */29public class WindowsOptions extends BaseOptions<WindowsOptions> implements30 SupportsAppOption<WindowsOptions>,31 SupportsAppArgumentsOption<WindowsOptions>,32 SupportsAppTopLevelWindowOption<WindowsOptions>,33 SupportsAppWorkingDirOption<WindowsOptions>,34 SupportsCreateSessionTimeoutOption<WindowsOptions>,35 SupportsMsWaitForAppLaunchOption<WindowsOptions>,36 SupportsMsExperimentalWebDriverOption<WindowsOptions>,37 SupportsSystemPortOption<WindowsOptions>,38 SupportsPrerunOption<WindowsOptions, PowerShellData>,39 SupportsPostrunOption<WindowsOptions, PowerShellData> {40 public WindowsOptions() {41 setCommonOptions();42 }43 public WindowsOptions(Capabilities source) {44 super(source);45 setCommonOptions();46 }47 public WindowsOptions(Map<String, ?> source) {48 super(source);49 setCommonOptions();50 }51 private void setCommonOptions() {52 setPlatformName(MobilePlatform.WINDOWS);53 setAutomationName(AutomationName.WINDOWS);54 }55 /**56 * An object containing either script or command key. The value of57 * each key must be a valid PowerShell script or command to be58 * executed prior to the WinAppDriver session startup.59 * See60 * https://github.com/appium/appium-windows-driver#power-shell-commands-execution61 * for more details.62 *63 * @param script E.g. {script: 'Get-Process outlook -ErrorAction SilentlyContinue'}.64 * @return self instance for chaining.65 */66 public WindowsOptions setPrerun(PowerShellData script) {67 return amend(PRERUN_OPTION, script.toMap());68 }69 /**70 * Get the prerun script.71 *72 * @return Prerun script.73 */74 public Optional<PowerShellData> getPrerun() {75 //noinspection unchecked76 return Optional.ofNullable(getCapability(PRERUN_OPTION))77 .map((v) -> new PowerShellData((Map<String, Object>) v));78 }79 /**80 * An object containing either script or command key. The value of81 * each key must be a valid PowerShell script or command to be82 * executed after an WinAppDriver session is finished.83 * See84 * https://github.com/appium/appium-windows-driver#power-shell-commands-execution85 * for more details.86 *87 * @param script E.g. {script: 'Get-Process outlook -ErrorAction SilentlyContinue'}.88 * @return self instance for chaining.89 */90 public WindowsOptions setPostrun(PowerShellData script) {91 return amend(POSTRUN_OPTION, script.toMap());92 }93 /**94 * Get the postrun script.95 *96 * @return Postrun script.97 */98 public Optional<PowerShellData> getPostrun() {99 //noinspection unchecked100 return Optional.ofNullable(getCapability(POSTRUN_OPTION))101 .map((v) -> new PowerShellData((Map<String, Object>) v));102 }103}...

Full Screen

Full Screen

WindowsDriverManager.java

Source:WindowsDriverManager.java Github

copy

Full Screen

...7import com.chameleon.selenium.DriverType;8import com.chameleon.selenium.elements.Element;9import io.appium.java_client.windows.WindowsDriver;10public class WindowsDriverManager extends DriverManager {11 private WindowsOptions options = null;12 public WindowsDriverManager() {13 throw new AutomationException("Windows driver cannot be started without options. Create WindowsOptions and pass in through Driver Factory");14 }15 public WindowsDriverManager(WindowsOptions options) {16 this.options = options;17 }18 @Override19 public void startService() {20 // if (null == driverService.get()) {21 // try {22 // driverService.set(new AppiumServiceBuilder()23 // // .withLogFile(logFile)24 // // .usingDriverExecutable(driverExecutable)25 // // .withAppiumJS(appiumJs)26 // .withIPAddress(AppiumServiceBuilder.DEFAULT_LOCAL_IP_ADDRESS)27 // .usingAnyFreePort()28 // // .usingPort(4723)29 // .withArgument(GeneralServerFlag.SESSION_OVERRIDE)...

Full Screen

Full Screen

WindowsApplication.java

Source:WindowsApplication.java Github

copy

Full Screen

1package tests.applications.windowsApp;2import aquality.selenium.core.applications.IApplication;3import io.appium.java_client.windows.WindowsDriver;4import io.appium.java_client.windows.options.WindowsOptions;5import org.openqa.selenium.remote.RemoteWebDriver;6import java.net.URL;7import java.time.Duration;8import java.util.concurrent.TimeUnit;9public class WindowsApplication implements IApplication {10 private long implicitWaitSeconds;11 private final WindowsDriver driver;12 WindowsApplication(long implicitWaitSeconds, String appPath, URL serviceUrl) {13 WindowsOptions options = new WindowsOptions();14 options.setApp(appPath);15 driver = new WindowsDriver(serviceUrl, options);16 setImplicitWaitTimeout(Duration.ofSeconds(implicitWaitSeconds));17 }18 @Override19 public RemoteWebDriver getDriver() {20 return driver;21 }22 @Override23 public boolean isStarted() {24 return driver.getSessionId() != null;25 }26 @Override27 public void setImplicitWaitTimeout(Duration value) {...

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 WindowsOptions

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful