Exemplo n.º 1
0
        public void TestAreaButtonClick()
        {
            PointerInputDevice mouseDevice = new PointerInputDevice(PointerKind.Touch);

            var editButton     = session.FindElementByAccessibilityId("EditButton");
            var areaButton     = session.FindElementByAccessibilityId("AreaButton");
            var plusButton     = session.FindElementByAccessibilityId("IncreaseDrawingAreaButton");
            var minusButton    = session.FindElementByAccessibilityId("DecreaseDrawingAreaButton");
            var drawAreaButton = session.FindElementByAccessibilityId("DrawAreaButton");
            var doneButton     = session.FindElementByAccessibilityId("DoneDrawingAreaButton");

            Assert.AreNotEqual(editButton, null);
            Assert.AreNotEqual(areaButton, null);
            Assert.AreNotEqual(plusButton, null);
            Assert.AreNotEqual(minusButton, null);
            Assert.AreNotEqual(drawAreaButton, null);
            Assert.AreNotEqual(doneButton, null);

            Assert.IsFalse(plusButton.Enabled);
            Assert.IsFalse(minusButton.Enabled);
            Assert.IsFalse(drawAreaButton.Enabled);
            Assert.IsFalse(doneButton.Enabled);

            editButton.Click();
            Thread.Sleep(10000);
            areaButton.Click();
            Thread.Sleep(10000);

            Assert.IsTrue(plusButton.Enabled);
            Assert.IsTrue(minusButton.Enabled);
            Assert.IsTrue(drawAreaButton.Enabled);
            Assert.IsTrue(doneButton.Enabled);
        }
Exemplo n.º 2
0
        public void TestEditButtonClick()
        {
            PointerInputDevice mouseDevice = new PointerInputDevice(PointerKind.Touch);

            var editButton  = session.FindElementByAccessibilityId("EditButton");
            var clearButton = session.FindElementByAccessibilityId("ClearButton");
            var loadButton  = session.FindElementByAccessibilityId("LoadButton");
            var saveButton  = session.FindElementByAccessibilityId("SaveButton");

            Assert.AreNotEqual(editButton, null);
            Assert.AreNotEqual(clearButton, null);
            Assert.AreNotEqual(loadButton, null);
            Assert.AreNotEqual(saveButton, null);

            Assert.IsFalse(clearButton.Enabled);
            Assert.IsFalse(loadButton.Enabled);
            Assert.IsFalse(saveButton.Enabled);

            editButton.Click();

            Thread.Sleep(10000);

            Assert.IsTrue(clearButton.Enabled);
            Assert.IsTrue(loadButton.Enabled);
            Assert.IsTrue(saveButton.Enabled);

            editButton.Click();
            Thread.Sleep(10000);
            loadButton.Click();
            Thread.Sleep(10000);
        }
        private void Flick(AndroidDriver <AppiumWebElement> driver, AppiumWebElement element, UpOrDown direction)
        {
            int moveYDirection;

            if (direction == UpOrDown.Down)
            {
                moveYDirection = 600;
            }
            else
            {
                moveYDirection = -600;
            }

            var            input   = new PointerInputDevice(PointerKind.Touch);
            ActionSequence FlickUp = new ActionSequence(input);

            FlickUp.AddAction(input.CreatePointerMove(element, 0, 0, TimeSpan.Zero));
            FlickUp.AddAction(input.CreatePointerDown(MouseButton.Left));

            FlickUp.AddAction(input.CreatePointerMove(element, 0, moveYDirection, TimeSpan.FromMilliseconds(200)));
            FlickUp.AddAction(input.CreatePointerUp(MouseButton.Left));
            driver.PerformActions(new List <ActionSequence>()
            {
                FlickUp
            });
        }
Exemplo n.º 4
0
        private void ScrollToEnd(WindowsDriver <WindowsElement> driver, AppiumWebElement element)
        {
            var            input       = new PointerInputDevice(PointerKind.Mouse);
            ActionSequence scrollToEnd = new ActionSequence(input);

            scrollToEnd.AddAction(input.CreatePointerMove(element, 0, 0, TimeSpan.Zero));
            scrollToEnd.AddAction(input.CreatePointerDown(MouseButton.Middle));
            scrollToEnd.AddAction(input.CreatePointerMove(element, 0, 600, TimeSpan.FromMilliseconds(200)));
            scrollToEnd.AddAction(input.CreatePointerUp(MouseButton.Middle));
            driver.PerformActions(new List <ActionSequence>()
            {
                scrollToEnd
            });
        }
        private void FlickUp(WindowsDriver <WindowsElement> driver, AppiumWebElement element)
        {
            var            input   = new PointerInputDevice(PointerKind.Touch);
            ActionSequence FlickUp = new ActionSequence(input);

            FlickUp.AddAction(input.CreatePointerMove(element, 0, 0, TimeSpan.Zero));
            FlickUp.AddAction(input.CreatePointerDown(MouseButton.Left));
            FlickUp.AddAction(input.CreatePointerMove(element, 0, -300, TimeSpan.FromMilliseconds(200)));
            FlickUp.AddAction(input.CreatePointerUp(MouseButton.Left));
            driver.PerformActions(new List <ActionSequence>()
            {
                FlickUp
            });
        }
Exemplo n.º 6
0
        public void TestWriteButtonClick()
        {
            PointerInputDevice mouseDevice = new PointerInputDevice(PointerKind.Touch);

            var writeButton = session.FindElementByAccessibilityId("WriteButton");
            var dotButton   = session.FindElementByAccessibilityId("Dot");

            Assert.AreNotEqual(writeButton, null);
            Assert.AreNotEqual(dotButton, null);

            writeButton.Click();
            Thread.Sleep(10000);

            Assert.IsTrue(dotButton.Enabled);
        }
Exemplo n.º 7
0
        public void TestDoneButtonClick()
        {
            PointerInputDevice mouseDevice = new PointerInputDevice(PointerKind.Touch);

            var doneButton = session.FindElementByAccessibilityId("DoneDrawingAreaButton");
            var editButton = session.FindElementByAccessibilityId("EditButton");

            Assert.AreNotEqual(doneButton, null);
            Assert.AreNotEqual(editButton, null);

            doneButton.Click();
            Thread.Sleep(10000);

            Assert.IsTrue(editButton.Enabled);
        }
Exemplo n.º 8
0
        public void TestIncreaseAreaButtonClick()
        {
            PointerInputDevice mouseDevice = new PointerInputDevice(PointerKind.Touch);

            var plusButton = session.FindElementByAccessibilityId("IncreaseDrawingAreaButton");
            var areaText   = session.FindElementByAccessibilityId("AreaText");

            Assert.AreNotEqual(plusButton, null);

            Assert.AreEqual("6'' X 4''", areaText.Text);

            plusButton.Click();
            Thread.Sleep(10000);

            Assert.AreEqual("8'' X 6''", areaText.Text);
        }
        public void AddNewItemWithNewCategory()
        {
            var capabilities = new AppiumOptions();

            capabilities.AddAdditionalCapability(MobileCapabilityType.App, "8b831c56-bc54-4a8b-af94-a448f80118e7_sezxftbtgh66j!App");
            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Windows");
            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "WindowsPC");

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

            _appiumLocalService.Start();
            var driver = new WindowsDriver <WindowsElement>(_appiumLocalService, capabilities);

            // Create new Category item first
            var categoryButton = driver.FindElement(MobileBy.AccessibilityId("AddCategory"));

            categoryButton.Click();

            // fill out the form for a new category
            var categoryName = driver.FindElement(MobileBy.AccessibilityId("categoryName"));

            categoryName.Clear();
            categoryName.SendKeys("New category from automation");

            //save category
            var saveCategory = driver.FindElement(MobileBy.AccessibilityId("Save"));

            saveCategory.Click();

            var el1 = driver.FindElementByAccessibilityId("Add");

            el1.Click();

            var elItemText = driver.FindElementByAccessibilityId("ItemText");

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

            var elItemDetail = driver.FindElementByAccessibilityId("ItemDescription");

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

            var elItemCategory = driver.FindElement(MobileBy.AccessibilityId("ItemCategory"));

            elItemCategory.Click();

            var categoryListItem = elItemCategory.FindElement(By.Name("New category from automation"));

            categoryListItem.Click();

            var elSave = driver.FindElementByAccessibilityId("Save");

            elSave.Click();
            elSave.ClearCache();

            //wait for progress bar to disapear
            var wait = new DefaultWait <WindowsDriver <WindowsElement> >(driver)
            {
                Timeout         = TimeSpan.FromSeconds(60),
                PollingInterval = TimeSpan.FromMilliseconds(500)
            };

            wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
            wait.Until(d => d.FindElementByName("Second item"));

            var listview = driver.FindElementByAccessibilityId("ItemsListView");

            //now use wait to scroll untill we find item
            wait = new DefaultWait <WindowsDriver <WindowsElement> >(driver)
            {
                Timeout         = TimeSpan.FromSeconds(60),
                PollingInterval = TimeSpan.FromMilliseconds(500)
            };
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException));

            var elementfound = wait.Until(d =>
            {
                var input = new PointerInputDevice(PointerKind.Touch);
                ActionSequence FlickUp = new ActionSequence(input);
                FlickUp.AddAction(input.CreatePointerMove(listview, 0, 0, TimeSpan.Zero));
                FlickUp.AddAction(input.CreatePointerDown(MouseButton.Left));
                FlickUp.AddAction(input.CreatePointerMove(listview, 0, -300, TimeSpan.FromMilliseconds(200)));
                FlickUp.AddAction(input.CreatePointerUp(MouseButton.Left));
                driver.PerformActions(new List <ActionSequence>()
                {
                    FlickUp
                });

                return(d.FindElementByName("This is a new Item"));
            });

            Assert.IsTrue(elementfound != null);

            driver.CloseApp();
        }
Exemplo n.º 10
0
        public void AddNewItemWithNewCategory()
        {
            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);

            // Create new Category item first
            var categoryButton = driver.FindElement(MobileBy.AccessibilityId("AddCategory"));

            categoryButton.Click();

            // fill out the form for a new category
            var categoryName = driver.FindElement(MobileBy.AccessibilityId("categoryName"));

            categoryName.Clear();
            categoryName.SendKeys("New category from automation");

            //save category
            var saveCategory = driver.FindElement(MobileBy.AccessibilityId("Save"));

            saveCategory.Click();

            var el1 = driver.FindElementByAccessibilityId("Add");

            el1.Click();

            var elItemText = driver.FindElementByAccessibilityId("ItemText");

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

            var elItemDetail = driver.FindElementByAccessibilityId("ItemDescription");

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

            var elItemCategory = driver.FindElement(MobileBy.AccessibilityId("ItemCategory_Container"));

            elItemCategory.Click();

            var picker            = driver.FindElement(By.Id("android:id/contentPanel"));
            var categoryListItems = picker.FindElements(By.ClassName("android.widget.TextView"));

            foreach (var categoryElement in categoryListItems)
            {
                if (categoryElement.Text == "New category from automation")
                {
                    categoryElement.Click();
                }
            }


            var elSave = driver.FindElementByAccessibilityId("Save");

            elSave.Click();

            //wait for progress bar to disapear
            var wait = new DefaultWait <AndroidDriver <AppiumWebElement> >(driver)
            {
                Timeout         = TimeSpan.FromSeconds(60),
                PollingInterval = TimeSpan.FromMilliseconds(500)
            };

            wait.IgnoreExceptionTypes(typeof(NoSuchElementException));

            wait.Until(d => d.FindElement(MobileBy.AccessibilityId("Second item")));


            var listview = driver.FindElementByAccessibilityId("ItemsListView");

            //now use wait to scroll untill we find item

            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);
            };

            wait = new DefaultWait <AndroidDriver <AppiumWebElement> >(driver)
            {
                Timeout         = TimeSpan.FromSeconds(60),
                PollingInterval = TimeSpan.FromMilliseconds(1000)
            };
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
            AppiumWebElement elementfound = null;

            elementfound = wait.Until(d =>
            {
                var input = new PointerInputDevice(PointerKind.Touch);
                ActionSequence FlickUp = new ActionSequence(input);
                FlickUp.AddAction(input.CreatePointerMove(listview, 0, 0, TimeSpan.Zero));
                FlickUp.AddAction(input.CreatePointerDown(MouseButton.Left));

                FlickUp.AddAction(input.CreatePointerMove(listview, 0, -600, TimeSpan.FromMilliseconds(200)));
                FlickUp.AddAction(input.CreatePointerUp(MouseButton.Left));
                driver.PerformActions(new List <ActionSequence>()
                {
                    FlickUp
                });
                return(FindElementAction());
            });

            Assert.IsTrue(elementfound != null);

            driver.CloseApp();
        }