Пример #1
0
        public void TestDelete()
        {
            string name  = "TestDelete";
            string price = "423425";

            //Insert our item for delete
            driver.FindElementByName("INSERT").Click();
            driver.FindElementByAccessibilityId("insertTextBoxName").SendKeys(name);
            driver.FindElementByAccessibilityId("insertTextBoxPrice").SendKeys(price);
            driver.FindElementByAccessibilityId("changeButton").Click();

            //We check insert item and get it's ID
            driver.FindElementByName("SELECT").Click();
            AppiumWebElement listView = driver.FindElementByAccessibilityId("listBoxSelect");

            listView.Click();
            IList <AppiumWebElement> items = listView.FindElementsByXPath(".//child::*");
            List <string>            texts = new List <string>();

            foreach (AppiumWebElement item in items)
            {
                texts.Add(item.Text);
            }
            List <string> filteredList = texts.Where(x => x.Contains(name)).ToList();

            Assert.AreEqual(1, filteredList.Count, "Not 1 element");

            string deleteString = filteredList[0];
            string subString    = " " + name + " " + price;
            int    n            = deleteString.IndexOf(subString);
            string id           = deleteString.Remove(n, subString.Length);

            Console.WriteLine("ID = " + id);

            //delete our item
            driver.FindElementByName("DELETE").Click();
            driver.FindElementByAccessibilityId("deleteTextboxID").SendKeys(id);
            driver.FindElementByAccessibilityId("deleteButton").Click();

            //check delete sucsess
            driver.FindElementByName("SELECT").Click();
            listView = driver.FindElementByAccessibilityId("listBoxSelect");
            listView.Click();
            items = listView.FindElementsByXPath(".//child::*");
            texts = new List <string>();
            foreach (AppiumWebElement item in items)
            {
                texts.Add(item.Text);
            }
            filteredList = texts.Where(x => x.Contains(name + " " + price)).ToList();
            Assert.AreEqual(0, filteredList.Count, "Not delete");
        }
Пример #2
0
        /// <summary>
        /// This method find and initiate all items which can be used for working with table(Vertical scroll, Horizontal scroll, Right/Left arrows)
        /// </summary>
        private void InitAllScrollItems()
        {
            _scrollers = _table.FindElementsByXPath("//ScrollBar[@Name='scroll bar']/Thumb[@Name='Position']");
            if (_scrollers.Count != 0)
            {
                foreach (AppiumWebElement element in _scrollers)
                {
                    if (element.Rect.Width > element.Rect.Height)
                    {
                        _hScroller = element;
                    }
                    else
                    {
                        _vScroller = element;
                    }
                }
            }

            if (_hScroller != null)
            {
                _hScrollerRightArrow = _table.FindElementByXPath("//ScrollBar[@Name='scroll bar']/Button[@Name='Column Right']");
                _hScrollerLeftArrow  = _table.FindElementByXPath("//ScrollBar[@Name='scroll bar']/Button[@Name='Column Left']");
            }

            if (_vScroller != null)
            {
                _vScrollerDownArrow = _table.FindElementByXPath("//ScrollBar[@Name='scroll bar']/Button[@Name='Line Down']");
                _vScrollerUpArrow   = _table.FindElementByXPath("//ScrollBar[@Name='scroll bar']/Button[@Name='Line Up']");
            }
        }
Пример #3
0
        public void TestChange()
        {
            string name  = "TestChange";
            string price = "213";

            //We check if we have anything to change (suddenly the last test broke everything)
            AppiumWebElement         listView = driver.FindElementByAccessibilityId("listBoxSelect");
            IList <AppiumWebElement> items    = listView.FindElementsByXPath(".//child::*");
            List <string>            texts    = new List <string>();

            foreach (AppiumWebElement item in items)
            {
                texts.Add(item.Text);
            }
            Assert.IsTrue(texts.Contains("1 musli 89"), "Don't repeat. No data.");

            /// We change item
            driver.FindElementByName("UPDATE").Click();
            driver.FindElementByAccessibilityId("textBoxIdUpdate").SendKeys("1");
            driver.FindElementByAccessibilityId("updateTextboxName").SendKeys(name);
            driver.FindElementByAccessibilityId("updateTextboxPrice").SendKeys(price);
            driver.FindElementByAccessibilityId("updateButton").Click();

            //Go back and check that our changes have been accepted
            driver.FindElementByName("SELECT").Click();
            listView = driver.FindElementByAccessibilityId("listBoxSelect");
            listView.Click();
            items = listView.FindElementsByXPath(".//child::*");
            texts = new List <string>();
            foreach (AppiumWebElement item in items)
            {
                texts.Add(item.Text);
            }
            Assert.IsTrue(texts.Contains("1 " + name + " " + price), "Item didn't change");

            //Change the element back(what was done in the last test using the server side)
            driver.FindElementByName("UPDATE").Click();
            driver.FindElementByAccessibilityId("textBoxIdUpdate").SendKeys("1");
            driver.FindElementByAccessibilityId("updateTextboxName").SendKeys("musli");
            driver.FindElementByAccessibilityId("updateTextboxPrice").SendKeys("89");
            driver.FindElementByAccessibilityId("updateButton").Click();
        }
 public static IReadOnlyList <AppiumWebElement> GetChildren(this AppiumWebElement element) =>
 element.FindElementsByXPath("*/*");