Пример #1
0
        // ************ DATE 10/16/2020 ************
        // ***** IMPORTANT: All Input by XPATH will search an element and then simulates typing text into the element.
        // ************ --------------- ************
        #region BY XPATH


        /// <summary>
        /// Finds the first element in the screen that matches the xPath criteria and then simulates typing text into the element.
        /// </summary>
        /// <param name="inputText">The text to type into the element.</param>
        /// <param name="position">Position to match a specific element</param>
        /// <param name="elem">Represents the Enum in Share class</param>
        /// <param name="widget">boolean if this is a widget</param>
        public static void ByXPath(string inputText, int position, Share.Element elem = Share.Element.EditText, bool widget = true)
        {
            try
            {
                AppiumWebElement element = GetControl.ByXPath(position, elem, widget);
                element.Clear();
                element.SendKeys(inputText);
            }
            catch (Exception ex)
            {
                Assert.Fail("InputByXPath threw an exception: " + ex.Message);
            }
        }
Пример #2
0
        public void TopNav()
        {
            NewsApp.FindElementByName("My News").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("My Sources").Click();
            Thread.Sleep(2000);
            string text = NewsApp.FindElementByName("Your News. Your Sources.").Text.ToString();

            Assert.AreEqual("Your News. Your Sources.", text);
            NewsApp.FindElementByName("Top Stories").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("US").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("World").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("Good News").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("Politics").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("Opinion").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("Crime").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("Technology").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("Entertainment").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("Money").Click();
            Thread.Sleep(2000);
            NewsApp.FindElementByName("Sports").Click();
            Thread.Sleep(2000);
            AppiumWebElement searchbox = NewsApp.FindElementByName("Search");

            searchbox.Clear();
            searchbox.SendKeys("Trump\r\n");
            Thread.Sleep(3000);
            string txtBlock = NewsApp.FindElementByClassName("TextBlock").Text;

            Assert.AreEqual(txtBlock, "Trump");
        }
Пример #3
0
    public void AddTest()
    {
        AppiumWebElement el4 = (AppiumWebElement)driver.FindElementByAccessibilityId("Add");

        el4.Click();
        AppiumWebElement el5 = (AppiumWebElement)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.view.ViewGroup[1]/android.support.v4.view.ViewPager/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ListView/android.widget.LinearLayout[1]/android.view.ViewGroup/android.view.ViewGroup");

        el5.Click();
        el5.Clear();
        el5.SendKeys("New item");
        AppiumWebElement el6 = (AppiumWebElement)driver.FindElementByAccessibilityId("Save");

        el6.Click();
        AppiumWebElement el7 = (AppiumWebElement)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.view.ViewGroup/android.support.v4.view.ViewPager/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ListView/android.widget.LinearLayout[7]/android.view.ViewGroup/android.view.ViewGroup");

        el7.Click();
        AppiumWebElement el8 = (AppiumWebElement)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.view.ViewGroup/android.support.v4.view.ViewPager/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.widget.TextView");
        AppiumWebElement el9 = (AppiumWebElement)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.view.ViewGroup/android.support.v4.view.ViewPager/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.widget.ImageButton");

        el9.Click();
        Assert.IsTrue(el8.Text.Equals("New item"));
    }