- May 25, 2018
- admin
- 0
Sample Test Script for Android Emulator in Java
package webdriverPackage; import org.testng.annotations.Test; import io.appium.java_client.remote.MobileCapabilityType; import java.net.MalformedURLException; import java.net.URL; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; public class AndroidTEst { @Test public void AndroidEmulatorLaunch() throws MalformedURLException { RemoteWebDriver driver; //Setting Capabilities DriverOptions cap = new AppiumOptions(); //Create a object of capabilities cap.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Samsung Galaxy S9"); cap.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android"); cap.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "8.0.0"); cap.AddAdditionalCapability(MobileCapabilityType.BrowserName, "Chrome"); cap.AddAdditionalCapability(MobileCapabilityType.Udid, "192.168.219.103:5555"); driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub") ,cap); driver.get("https://www.Techtutorialz.com"); } }
// POM.XML
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.10</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.141.59</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server</artifactId> <version>3.141.59</version> </dependency> <dependency> <groupId>io.appium</groupId> <artifactId>java-client</artifactId> <version>4.1.2</version> </dependency>