public void StartingAndroidAppWithCapabilitiesAndServiceTest()
        {
            string app = Apps.get("androidApiDemos");

            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability(MobileCapabilityType.DeviceName, "Android Emulator");

            OptionCollector argCollector = new OptionCollector().AddArguments(GeneralOptionList.App(app))
                                           .AddArguments(GeneralOptionList.AutomationName(AutomationName.Appium));
            AppiumServiceBuilder builder = new AppiumServiceBuilder().WithArguments(argCollector);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(builder, capabilities);
                driver.CloseApp();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }
 public void TestCleanup()
 {
     if (_driver != null)
     {
         _driver.CloseApp();
     }
 }
 public void Restart()
 {
     _driver.CloseApp();
     _driver.Dispose();
     _driver = null;
     Init("RestartApp");
 }
        public void CloseAppTestCase()
        {
            AndroidDriver <IWebElement> driver = new AndroidDriver <IWebElement>(defaultUri, capabilities);

            server.respondTo("POST", "/appium/app/close", null);
            driver.CloseApp();
        }
Example #5
0
        public void StartingAndroidAppWithCapabilitiesOnTheServerSideTest()
        {
            var app = Apps.Get("androidApiDemos");

            var serverCapabilities = Env.ServerIsRemote()
                ? Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"))
                : Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"));

            var clientCapabilities = new AppiumOptions();

            clientCapabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            clientCapabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".view.WebView1");

            var argCollector = new OptionCollector().AddCapabilities(serverCapabilities);
            var builder      = new AppiumServiceBuilder().WithArguments(argCollector);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(builder, clientCapabilities);
                driver.CloseApp();
            }
            finally
            {
                driver?.Quit();
            }
        }
 public void TearDowwn()
 {
     if (driver != null)
     {
         driver.CloseApp();
     }
 }
        public void StartingAndroidAppWithCapabilitiesAndServiceTest()
        {
            DesiredCapabilities capabilities = Env.isSauce() ?
                                               Caps.getAndroid501Caps(Apps.get("androidApiDemos")) :
                                               Caps.getAndroid19Caps(Apps.get("androidApiDemos"));


            OptionCollector argCollector = new OptionCollector()
                                           .AddArguments(GeneralOptionList.OverrideSession()).AddArguments(GeneralOptionList.StrictCaps());
            AppiumServiceBuilder builder = new AppiumServiceBuilder().WithArguments(argCollector);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(builder, capabilities);
                driver.CloseApp();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }
        public void StartingAndroidAppWithCapabilitiesOnTheServerSideTest()
        {
            string app = Apps.get("androidApiDemos");

            DesiredCapabilities serverCapabilities = Env.isSauce() ?
                                                     Caps.getAndroid501Caps(Apps.get("androidApiDemos")) :
                                                     Caps.getAndroid19Caps(Apps.get("androidApiDemos"));

            DesiredCapabilities clientCapabilities = new DesiredCapabilities();

            clientCapabilities.SetCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            clientCapabilities.SetCapability(AndroidMobileCapabilityType.AppActivity, ".view.WebView1");

            OptionCollector      argCollector = new OptionCollector().AddCapabilities(serverCapabilities);
            AppiumServiceBuilder builder      = new AppiumServiceBuilder().WithArguments(argCollector);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(builder, clientCapabilities);
                driver.CloseApp();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }
Example #9
0
        public void initialize()
        {
            System.Environment.SetEnvironmentVariable("ANDROID_HOME", @"C:\Program Files (x86)\Android\android-sdk");
            System.Environment.SetEnvironmentVariable("JAVA_HOME", @"C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin");


            var capabilities = new AppiumOptions();

            //capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "5.0.1");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "com.yourcompany.conferenceapp");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, "mainactivity");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.Avd, "demo_device");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AvdArgs, "demo_device");
            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "demo_device");
            capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, "UiAutomator2");
            capabilities.AddAdditionalCapability(MobileCapabilityType.App, @"C:\source\hol-xamarin-beyond-the-basics\hol\hol-06\Solution\ConferenceApp.Android\bin\Debug\com.yourcompany.conferenceapp-Signed.apk");
            var currentPath = Directory.GetCurrentDirectory();

            Console.WriteLine($"Current path: {currentPath}");
            Uri serverUri = new Uri("http://127.0.0.1:4723/wd/hub");

            //var _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            //_appiumLocalService.Start(); ;
            driver = new AndroidDriver <AppiumWebElement>(serverUri, capabilities);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            driver.CloseApp();
        }
        public void TearDown()
        {
            driver?.CloseApp();

            if (driver.IsAppInstalled(appId))
            {
                driver.RemoveApp(appId);
            }
        }
Example #11
0
        public void BeforeAll()
        {
            var capabilities = Caps.GetAndroidCaps(Apps.Get("androidApiDemos"));

            var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;

            _driver = new AndroidDriver <IWebElement>(serverUri, capabilities, Env.InitTimeoutSec);
            _driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec;
            _driver.CloseApp();
        }
Example #12
0
        public void OneTimeTearDownBase()
        {
            // Close the app and quit the driver
            driver.CloseApp();
            driver.Quit();

            // Dispose of the Appium Local Service
            appiumLocalService.Dispose();

            // Stop and dispose the local Web API server
            this.testEventuresApp.Dispose();
        }
        public Appium()
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability(MobileCapabilityType.PlatformName, "Android");
            capabilities.SetCapability(MobileCapabilityType.PlatformVersion, "9.0");
            capabilities.SetCapability(MobileCapabilityType.DeviceName, "phone_1");
            capabilities.SetCapability(MobileCapabilityType.App, "C:\\whatsapp\\com.whatsapp.apk");

            driver = new AndroidDriver <AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
            driver.FindElementById("com.whatsapp:id/eula_accept").Click();
            driver.CloseApp();
        }
        public static void ClassInitialize(TestContext context)
        {
            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            var appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "android25-test");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.BrowserName, "Chrome");

            _driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, appiumOptions);
            _driver.CloseApp();
        }
        public void AddNewItem()
        {
            AndroidDriver <AppiumWebElement> driver = StartApp();

            // tap on second item
            var el1 = driver.FindElement(MobileBy.AccessibilityId("Add"));

            el1.Click();

            var elItemText = driver.FindElement(MobileBy.AccessibilityId("ItemText"));

            elItemText.Clear();
            elItemText.SendKeys("This is a new Item");

            var elItemDetail = driver.FindElement(MobileBy.AccessibilityId("ItemDescription"));

            elItemDetail.Clear();
            elItemDetail.SendKeys("These are the details");

            var elSave = driver.FindElement(MobileBy.AccessibilityId("Save"));

            elSave.Click();
            CreateScreenshot(driver);

            WaitForProgressbarToDisapear(driver);

            CreateScreenshot(driver);

            var scrollableElement = driver.FindElement(MobileBy.AccessibilityId("ItemsListView"));

            Func <AppiumWebElement> FindElementAction = () =>
            {
                // find all text views
                // check if the text matches
                var elements = driver.FindElementsByClassName("android.widget.TextView");
                foreach (var textView in elements)
                {
                    if (textView.Text == "This is a new Item")
                    {
                        return(textView);
                    }
                }
                return(null);
            };

            var elementFound = ScrollUntillItemFound(driver, scrollableElement, FindElementAction, 4);

            Assert.IsTrue(elementFound != null);
            driver.CloseApp();
        }
Example #16
0
        public static void ClassInitialize(TestContext context)
        {
            string testAppPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "ApiDemos-debug.apk");
            var    desiredCaps = new AppiumOptions();

            desiredCaps.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
            desiredCaps.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            desiredCaps.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            desiredCaps.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1");
            desiredCaps.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".ApiDemos");
            desiredCaps.AddAdditionalCapability(MobileCapabilityType.App, testAppPath);

            _driver = new AndroidDriver <AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), desiredCaps);
            _driver.CloseApp();
        }
Example #17
0
        public void MasterDetail()
        {
            System.Environment.SetEnvironmentVariable("ANDROID_HOME", @"C:\Program Files (x86)\Android\android-sdk");
            System.Environment.SetEnvironmentVariable("JAVA_HOME", @"C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin");

            var capabilities = new AppiumOptions();

            // automatic start of the emulator if not running
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.Avd, "demo_device");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AvdArgs, "-no-boot-anim -no-snapshot-load");
            capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true);
            // connecting to a device or emulator
            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "2471736c36037ece");
            capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, "UiAutomator2");
            // specifyig which app we want to install and launch
            var currentPath = Directory.GetCurrentDirectory();

            Console.WriteLine($"Current path: {currentPath}");
            var packagePath = Path.Combine(currentPath, @"..\..\..\AppsToTest\com.fluentbytes.carvedrock-x86.apk");

            packagePath = Path.GetFullPath(packagePath);
            Console.WriteLine($"Package path: {packagePath}");
            capabilities.AddAdditionalCapability(MobileCapabilityType.App, packagePath);

            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "com.fluentbytes.carvedrock");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, "crc641782d5af3c9cf50a.MainActivity");

            var _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();

            _appiumLocalService.Start();;
            var driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, capabilities);
            // tap on second item
            var el1 = driver.FindElement(MobileBy.AccessibilityId("Second item"));

            el1.Click();

            var el2 = driver.FindElement(MobileBy.AccessibilityId("ItemText"));

            Assert.IsTrue(el2.Text == "Second item");

            driver.PressKeyCode(AndroidKeyCode.Back);

            var el3 = driver.FindElement(MobileBy.AccessibilityId("Fourth item"));

            Assert.IsTrue(el3 != null);

            driver.CloseApp();
        }
        public static void ClassInitialize(TestContext context)
        {
            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            string testAppPath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "selendroid-test-app-0.10.0.apk");
            var    appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "android25-test");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.selendroid.testapp");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, "HomeScreenActivity");

            _driver = new AndroidDriver <AppiumWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
            _driver.CloseApp();
        }
        public static void ClassInitialize(TestContext context)
        {
            var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());

            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            var desiredCaps = new DesiredCapabilities();

            desiredCaps.SetCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformName, "Android");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformVersion, "7.1");
            desiredCaps.SetCapability(MobileCapabilityType.BrowserName, "Chrome");

            _driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, desiredCaps);
            _driver.CloseApp();
        }
Example #20
0
        public void TestMethod1()
        {
            driver.LaunchApp();
            var         el1 = driver.FindElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.support.v4.widget.DrawerLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[1]/android.view.ViewGroup/android.support.v4.view.ViewPager/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.view.ViewGroup[4]/android.view.ViewGroup/android.widget.FrameLayout");
            TouchAction a   = new TouchAction(driver);

            a.Tap(el1);

            el1.Click();
            var el2 = driver.FindElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.support.v4.widget.DrawerLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[1]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.widget.FrameLayout[2]");


            Assert.IsTrue(el2.Text.Contains("will"));

            driver.CloseApp();
        }
Example #21
0
        public static void ClassInitialize(TestContext context)
        {
            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            string testAppPath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "ApiDemos-debug.apk");
            var    appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "com.example.android.apis");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".view.ControlsMaterialDark");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.App, testAppPath);

            _driver = new AndroidDriver <AndroidElement>(_appiumLocalService, appiumOptions);
            _driver.CloseApp();
        }
Example #22
0
        /// <summary>
        /// 终止当前打开的应用程序
        /// </summary>
        /// <param name="logOutput"> 是否打印执行日志 </param>
        public void CurrentAppKill(bool logOutput = true)
        {
            try
            {
                AndroidDriver.CloseApp();

                if (logOutput)
                {
                    LogServe.Info("终止当前打开的应用程序");
                }
            }

            catch (Exception err)
            {
                LogServe.Error($"Error:: 终止当前打开的应用程序异常:: { err.Message }"); throw;
            }
        }
Example #23
0
        public void StartingAndroidAppWithCapabilitiesOnlyTest()
        {
            var app          = Apps.Get("androidApiDemos");
            var capabilities =
                Caps.GetAndroidUIAutomatorCaps(app);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(capabilities);
                driver.CloseApp();
            }
            finally
            {
                driver?.Quit();
            }
        }
        public static void ClassInitialize(TestContext context)
        {
            var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());

            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            string testAppPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "selendroid-test-app-0.10.0.apk");
            var    desiredCaps = new DesiredCapabilities();

            desiredCaps.SetCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformName, "Android");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformVersion, "7.1");
            desiredCaps.SetCapability(AndroidMobileCapabilityType.AppPackage, "io.selendroid.testapp");
            desiredCaps.SetCapability(AndroidMobileCapabilityType.AppActivity, "HomeScreenActivity");

            _driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, desiredCaps);
            _driver.CloseApp();
        }
        public static void ClassInitialize(TestContext context)
        {
            ////var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());
            ////_appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            ////_appiumLocalService.Start();
            string testAppPath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "ApiDemos-debug.apk");
            var    appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "android25-test");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".ApiDemos");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.App, testAppPath);

            _driver = new AndroidDriver <AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
            _driver.CloseApp();
        }
        public void BeforeAll()
        {
            DesiredCapabilities capabilities = Env.isSauce() ?
                                               Caps.getAndroid501Caps(Apps.get("androidApiDemos")) :
                                               Caps.getAndroid19Caps(Apps.get("androidApiDemos"));

            if (Env.isSauce())
            {
                capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME"));
                capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY"));
                capabilities.SetCapability("name", "android - complex");
                capabilities.SetCapability("tags", new string[] { "sample" });
            }
            Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.LocalServiceURIAndroid;

            driver = new AndroidDriver <AppiumWebElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
            driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC);
            driver.CloseApp();
        }
        public static void ClassInitialize(TestContext context)
        {
            var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());

            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            string testAppPath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "ApiDemos-debug.apk");
            var    appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".graphics.TouchRotateActivity");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.App, testAppPath);

            _driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, appiumOptions);
            _driver.CloseApp();
        }
Example #28
0
        private void button1_Click(object sender, EventArgs e)
        {
            //var capabilities = Caps.GetAndroidCaps(Apps.Get("androidApiDemos"));

            //var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
            //_driver = new AndroidDriver<IWebElement>(serverUri, capabilities, Env.InitTimeoutSec);
            //_driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec;
            //_driver.CloseApp();


            var capabilities = new AppiumOptions();

            capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, AutomationName.AndroidUIAutomator2);
            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "emulator-5554");
            capabilities.AddAdditionalCapability("appPackage", "com.google.android.youtube");
            _driver = new AndroidDriver <IWebElement>(new Uri("https://127.0.0.1:4723/wd/hub"), capabilities, Env.InitTimeoutSec);
            _driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec;
            _driver.CloseApp();
        }
Example #29
0
        public void TestMethod3()
        {
            AppiumDriver <AndroidElement> driver;
            DesiredCapabilities           cap = new DesiredCapabilities();

            cap.SetCapability("deviceName", "donatello");
            cap.SetCapability(AndroidMobileCapabilityType.AppPackage, "com.example.tirumalasettyn.myapplication");
            cap.SetCapability(AndroidMobileCapabilityType.AppActivity, "MainActivity");
            driver = new AndroidDriver <AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap);

            //check if we get the application loaded
            Assert.IsNotNull(driver.Context);

            //do the UI operation
            //driver.FindElementById("button").Click();

            driver.FindElementById("editText2").SendKeys("My Name is Naveen Tirumalasetty");
            //Assert.AreEqual("Hello World!", driver.FindElementByClassName("android.widget.TextView").Text, "Text dint match");
            driver.CloseApp();
        }
Example #30
0
        public void InstallWidget()
        {
            var height = driver.Manage().Window.Size.Height;
            var width  = driver.Manage().Window.Size.Width;

            driver.CloseApp();

            Thread.Sleep(1500);
            driver.Tap(1, width / 2, height / 2, 2000);
            Thread.Sleep(1500);
            driver.Tap(1, driver.FindElementByXPath("//*[@resource-id='com.android.launcher3:id/widget_button']"), 10);
            Thread.Sleep(1500);
            driver.Swipe(width * 3 / 4, height / 2, width / 10, height / 2, 1000);
            Thread.Sleep(1500);
            driver.Swipe(width * 3 / 4, height / 2, width / 10, height / 2, 1000);
            Thread.Sleep(1500);
            driver.Tap(1, driver.FindElementByXPath("//*[@resource-id='com.android.launcher3:id/widget_preview'][1]"), 3000);
            Thread.Sleep(1500);
            driver.Tap(1, driver.FindElementByXPath("//*[@resource-id='android:id/button1']"), 10);
        }