- May 25, 2018
- admin
- 0
Here is the SampleTest Script – Android Emulator
using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Remote; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SeleniumHelloWorld { public class Emulator { public IWebDriver driver; [TestFixtureSetUp] public void Class1() { //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"); //Connecting to Appium Server driver = new RemoteWebDriver(new Uri(“http://127.0.0.1:4723/wd/hub”), cap); }
//Test Case: [Test()] public void VerifyMenuSimulator() { //Test to login into app driver.FindElement(By.XPath(“//UIATextField[1]”)).SendKeys(“username”); driver.FindElement(By.XPath(“///UIASecureTextField[1]”)).SendKeys(“password”); driver.FindElement(By.XPath(“///UIAButton[1]”)).Click(); } Cleanup: [TestFixtureTearDown] public void End() { driver.Quit(); } } } }
Running test cases on Android emulator in Java..