public void deveSomarDoisValoress()
        {
            DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

            desiredCapabilities.SetCapability("platformName", "Android");
            desiredCapabilities.SetCapability("deviceName", "0030260344");
            desiredCapabilities.SetCapability("automationName", "uiautomator2");
            desiredCapabilities.SetCapability("appPackage", "com.google.android.calculator");
            desiredCapabilities.SetCapability("appActivity", "com.android.calculator2.CalculatorGoogle");

            AndroidDriver <AppiumWebElement> driver = new AndroidDriver <AppiumWebElement>(new Uri("http://localhost:4723/wd/hub"), desiredCapabilities);

            AppiumWebElement el1 = (AppiumWebElement)driver.FindElementById("com.google.android.calculator:id/digit_4");

            el1.Click();
            el1.Click();
            AppiumWebElement el2 = (AppiumWebElement)driver.FindElementByAccessibilityId("mais");

            el2.Click();
            AppiumWebElement el3 = (AppiumWebElement)driver.FindElementById("com.google.android.calculator:id/digit_4");

            el3.Click();
            AppiumWebElement el4 = (AppiumWebElement)driver.FindElementById("com.google.android.calculator:id/result");

            Assert.AreEqual("8", el4.Text);
            driver.Quit();
        }
Пример #2
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");
        }
Пример #3
0
        public void EditMovieTest()
        {
            string username = "******"; string password = "******";
            WindowsDriver <WindowsElement> session = Initialize();

            session = WorkflowLogin(session, username, password);
            Assert.AreEqual(session.WindowHandles.Count, 1);

            // Main Page
            session.SwitchTo().Window(session.WindowHandles.Last());
            Assert.IsTrue(session.FindElementsByClassName("DataGridRow").Count > 0);

            WindowsElement   eEditRow              = session.FindElementsByClassName("DataGridRow").ElementAt(0);
            AppiumWebElement eEditButton           = eEditRow.FindElementByName("Edit");

            eEditButton.Click();

            session.SwitchTo().Window(session.WindowHandles[0]);
            WindowsElement eEditSubmit = session.FindElementByAccessibilityId("btnSubmit");

            eEditSubmit.Click();

            WindowsElement eSubmitMessage = session.FindElementByName("Movie Submit Success!");

            Assert.AreEqual(eSubmitMessage.Text, "Movie Submit Success!");
        }
Пример #4
0
        public static AppiumWebElement OpenRibbon(string[] strRibbon)
        {
            int nCnt = 0;
            AppiumWebElement retDialog = jupiter.FindElementByName("Application menu");//to initialize;

            foreach (string strName in strRibbon)
            {
                if (nCnt++ == 0)
                {
                    retDialog = toolBar.FindElementByName(strName);
                }
                else
                {
                    retDialog = jupiter.FindElementByName(strName);
                }
                if (retDialog != null)
                {
                    retDialog.Click();
                }
                else
                {
                    return(null);
                }
                Thread.Sleep(1000);
            }
            return(retDialog);
        }
        public void CreateAndroidDriverInGridWithWebAppByDefaultPasses()
        {
            System.Console.WriteLine($"Thread # [{System.Threading.Thread.CurrentThread.ManagedThreadId}]");
            //Check if this is true for IOSdriver
            AndroidDriver <AppiumWebElement> driver = MobileDriver.Get <AndroidDriver <AppiumWebElement> >();
            // TestLogs.WriteDeviceLogs();
            ServerCommandExecutor executor = new ServerCommandExecutor(this.GetParameters().ServerUri, driver.SessionId);

            Console.WriteLine($"Current device orientation is:{driver.Orientation}");
            executor.Execute("setOrientation", new Dictionary <string, object> {
                { "orientation", "LANDSCAPE" }
            });
            Console.WriteLine($"New device orientation is: {driver.Orientation}");
            TestContext.WriteLine($"Web app SessionId is:[{driver.SessionId}]");
            Assert.NotNull(driver, $"driver cannot be null");
            /*System.Console.WriteLine($"Server running test [{driver.PlatformName}]");*/
            driver.Navigate().GoToUrl("http://google.com");
            System.Console.WriteLine($"Curretn activity:{driver.CurrentActivity}");

            Wait.ForPageToLoad();
            AppiumWebElement searchTextControl = driver.FindElement(By.CssSelector("div.SDkEP input.gLFyf"), 10);

            searchTextControl.Click();
            searchTextControl.SendKeys("Hello there@@");
            Wait.Seconds(3);
            Assert.AreEqual(driver.Contexts.Count, 2, "Multiple Contexts");
            Assert.AreEqual(driver.Context.ToString(), "CHROMIUM", "Expected Chromium context");
            OpenQA.Selenium.Remote.Response result1 = executor.Execute("getAvailableLogTypes");
            Console.WriteLine($"Supported Log Types:\n {result1.ToJson()}");
        }
Пример #6
0
        public void deveSomarDoisValores()
        {
            DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

            desiredCapabilities.SetCapability("platformName", "Android");
            desiredCapabilities.SetCapability("deviceName", "emulator-5554");
            desiredCapabilities.SetCapability("automationName", "uiautomator2");
            desiredCapabilities.SetCapability("appPackage", "com.android.calculator2");
            desiredCapabilities.SetCapability("appActivity", "com.android.calculator2.Calculator");

            AndroidDriver <AppiumWebElement> driver = new AndroidDriver <AppiumWebElement>(new Uri("http://localhost:4723/wd/hub"), desiredCapabilities);

            AppiumWebElement el3 = (AppiumWebElement)driver.FindElementById("com.android.calculator2:id/digit_2");

            el3.Click();
            AppiumWebElement el4 = (AppiumWebElement)driver.FindElementByAccessibilityId("plus");

            el4.Click();
            AppiumWebElement el5 = (AppiumWebElement)driver.FindElementById("com.android.calculator2:id/digit_2");

            el5.Click();
            AppiumWebElement el6 = (AppiumWebElement)driver.FindElementById("com.android.calculator2:id/result");

            //System.out.print(el6.Text);

            Assert.AreEqual("4", el6.Text);
            driver.Quit();
        }
Пример #7
0
        public void SoapUITest()
        {
            AppiumOptions appOptions = new AppiumOptions();

            appOptions.AddAdditionalCapability("app", @"C:\Program Files (x86)\SmartBear\SoapUI-5.5.0\bin\SoapUI-5.5.0.exe");
            appOptions.AddAdditionalCapability("ms:waitForAppLaunch", "15");
            WindowsDriver <WindowsElement> SOAPUISession = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), appOptions);

            Console.WriteLine("WindowsDriver is initialized");
            Console.WriteLine("Application Title:" + SOAPUISession.Title);
            AppiumWebElement EndPointExpClose = SOAPUISession.FindElementByName("Endpoint Explorer").FindElementByName("Close");

            EndPointExpClose.Click();
            Console.WriteLine("Endpoint explorer window is closed");

            SOAPUISession.Manage().Window.Maximize();
            Console.WriteLine("SOAPUI tool window is maximized");

            SOAPUISession.FindElementByName("Close").Click();
            Console.WriteLine("Close button is clicked");

            SOAPUISession.FindElementByName("Question").SendKeys(Keys.Enter);

            Console.WriteLine("SOAPUI application is closed");

            SOAPUISession.Quit();
        }
Пример #8
0
        static void OperatePublicItem(AppiumWebElement element)
        {
            // 公众号列表项
            element.Click();
            Thread.Sleep(TimeSpan.FromSeconds(1));

            // 详细信息
            ClickElement(Const.PublicDetailsId);

            // 滚动至全部消息按钮可见状态
            var screenSize = _driver.Manage().Window.Size;

            ScrollToBottom(screenSize, Const.PublicDetailsBottomId);

            // 点击全部消息
            ClickElement(Const.PublicDetailsBottomId, TimeSpan.FromSeconds(5));

            while (HasProgressBar())
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
            }

            OperateHistoryMsgItem();

            _driver.PressKeyCode(AndroidKeyCode.Back);
            Thread.Sleep(TimeSpan.FromSeconds(1));

            _driver.PressKeyCode(AndroidKeyCode.Back);
            Thread.Sleep(TimeSpan.FromSeconds(1));

            _driver.PressKeyCode(AndroidKeyCode.Back);
            Thread.Sleep(TimeSpan.FromSeconds(1));
        }
Пример #9
0
 public void OpenCortanaWindow()
 {
     if (CortanaButton != null)
     {
         CortanaButton.Click();
     }
 }
Пример #10
0
        /// <summary>
        /// Sets the selected date of the calendar view.
        /// </summary>
        /// <param name="date">The date to set to.</param>
        public void SetDate(DateTime date)
        {
            string expectedDay    = date.ToString("%d");
            string expectedHeader = date.ToString("MMMM yyyy");

            string   currentHeader   = this.HeaderButton.Element.GetAttribute("Name");
            DateTime currentViewDate = this.GetCurrentViewDate(currentHeader);

            while (!expectedHeader.Equals(currentHeader, StringComparison.CurrentCultureIgnoreCase))
            {
                if (currentViewDate.Date > date.Date)
                {
                    this.PreviousMonthButton.Click();
                }
                else
                {
                    this.NextMonthButton.Click();
                }

                Thread.Sleep(10);

                currentHeader = this.HeaderButton.Element.GetAttribute("Name");
            }

            AppiumWebElement item = this.Days.FirstOrDefault(
                element => element.GetAttribute("Name").Equals(expectedDay, StringComparison.CurrentCultureIgnoreCase));

            item.Click();
        }
Пример #11
0
        public void EditUserTest()
        {
            string username = "******"; string password = "******";
            WindowsDriver <WindowsElement> session = Initialize();

            session = WorkflowLogin(session, username, password);
            Assert.AreEqual(session.WindowHandles.Count, 1);

            // Main Page
            session.SwitchTo().Window(session.WindowHandles.Last());
            Assert.IsTrue(session.FindElementsByClassName("DataGridRow").Count > 0);

            WindowsElement eUser = session.FindElementByAccessibilityId("btnUser");

            eUser.Click();

            session.SwitchTo().Window(session.WindowHandles[0]);
            Assert.IsTrue(session.FindElementsByClassName("DataGridRow").Count > 0);

            WindowsElement   eRow      = session.FindElementsByClassName("DataGridRow").ElementAt(9);
            AppiumWebElement eCheckbox = eRow.FindElementByClassName("CheckBox");

            eCheckbox.Click();

            session.SwitchTo().Window(session.WindowHandles[0]);
            WindowsElement eYes = session.FindElementByName("Yes");

            eYes.Click();
            Assert.IsTrue(session.FindElementsByClassName("DataGridRow").Count > 0);
        }
Пример #12
0
        /// <summary>
        /// Clicks on a tab in the view with the specified item name.
        /// </summary>
        /// <param name="name">
        /// The name of the item to click.
        /// </param>
        public void SelectTab(string name)
        {
            this.VerifyElementShown(this.tabListViewQuery, TimeSpan.FromSeconds(2));
            AppiumWebElement item = this.Tabs.FirstOrDefault(element => element.VerifyNameOrAutomationIdEquals(name));

            item.Click();
        }
Пример #13
0
        /// <summary>
        /// Clicks on an item in the list view with the specified item name.
        /// </summary>
        /// <param name="name">
        /// The name of the item to click.
        /// </param>
        public void ClickItem(string name)
        {
            this.VerifyElementsShown(this.gridViewItemQuery, TimeSpan.FromSeconds(2));

            AppiumWebElement item = this.Items.FirstOrDefault(element => element.VerifyNameOrAutomationIdEquals(name));

            item.Click();
        }
Пример #14
0
        private void SetLayoutName(string name)
        {
            AppiumWebElement textBox = creatorWindow.FindElementByClassName("TextBox");

            textBox.Click();
            textBox.SendKeys(Keys.Control + "a");
            textBox.SendKeys(Keys.Backspace);
            textBox.SendKeys(name);
        }
Пример #15
0
    public void zAboutTest()
    {
        AppiumWebElement el10 = (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.widget.HorizontalScrollView/android.widget.LinearLayout/android.support.v7.app.ActionBar.Tab[2]/android.widget.TextView");

        el10.Click();
        AppiumWebElement el11 = (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.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[4]/android.widget.Button");

        el11.Click();
    }
Пример #16
0
        private void SelectCategory(NcpAppElement categoryElement)
        {
            AndroidElement categoryMenuElement = AppAccess.GetElementByClassNameAndText("android.widget.TextView", new string[] { "分类" }, true, true, true);

            categoryMenuElement.Click();

            AppiumWebElement cagtegoryElement = this.GetCategoryElement(categoryElement.Name, categoryElement.Attributes["count"]);

            cagtegoryElement.Click();
        }
Пример #17
0
    public void DetailTest()
    {
        AppiumWebElement el1 = (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[1]/android.view.ViewGroup/android.view.ViewGroup");

        el1.Click();
        AppiumWebElement el2 = (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 el3 = (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");

        el3.Click();
        Assert.IsTrue(el2.Text.Equals("First item"));
    }
Пример #18
0
            public void GridEnterTextTest()
            {
                // Type mixed text and apply shift modifier to 7890_ to generate corresponding symbols
                Thread.Sleep(TimeSpan.FromSeconds(2));
                AppiumWebElement firstNameCell = dataGrid.FindElementByName("Row 0").FindElementByName("Name Row 0");

                firstNameCell.Click();
                firstNameCell.SendKeys("abcdeABCDE 12345" + Keys.Shift + "7890-" + Keys.Shift + @"!@#$%");
                firstNameCell.SendKeys(Keys.Enter);
                Assert.AreEqual(@"abcdeABCDE 12345&*()_!@#$%", firstNameCell.Text);
            }
Пример #19
0
        /// <summary>
        /// Selects a sample from the available options with the given name.
        /// </summary>
        /// <typeparam name="TPage">The type of page to return.</typeparam>
        /// <param name="name">The name of the sample to click.</param>
        /// <returns>The <see cref="TPage"/> instance.</returns>
        public TPage SelectSample <TPage>(string name) where TPage : BasePage
        {
            this.SearchForSample(name);

            AppiumWebElement item = this.SamplePicker.Items.FirstOrDefault(i =>
                                                                           i.FindElement(By.XPath($".//*[@ClassName='TextBlock'][@Name='{name}']")) != null);

            item.Click();

            return(Activator.CreateInstance <TPage>());
        }
Пример #20
0
 /// <summary>
 /// This method Clicks an element
 /// </summary>
 /// <param name="element">element to be clicked</param>
 public static void Click(AppiumWebElement element)
 {
     try
     {
         element.Click();
     }
     catch (Exception e)
     {
         PrintException(e);
     }
 }
Пример #21
0
        // ************ DATE 10/16/2020 ************
        // ***** IMPORTANT: All Click by ID will search an element and then click it.
        // ************ --------------- ************
        #region BY ID


        /// <summary>
        /// Finds the first element in the screen that matches the id criteria and then click it.
        /// </summary>
        /// <param name="id">Id to find the object</param>
        public static void ById(string id)
        {
            try
            {
                AppiumWebElement element = GetControl.ById(id);
                element.Click();
            }
            catch (Exception ex)
            {
                Assert.Fail("ClickById threw an exception: " + ex.Message);
            }
        }
Пример #22
0
        // ************ DATE 10/16/2020 ************
        // ***** IMPORTANT: All Click by XPATH will search an element and then click it.
        // ************ --------------- ************
        #region BY XPATH


        /// <summary>
        /// Finds the first element in the screen that matches the xPath criteria and then click it.
        /// </summary>
        /// <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(int position, Share.Element elem = Share.Element.EditText, bool widget = true)
        {
            try
            {
                AppiumWebElement element = GetControl.ByXPath(position, elem, widget);
                element.Click();
            }
            catch (Exception ex)
            {
                Assert.Fail("ClickByXPath threw an exception: " + ex.Message);
            }
        }
Пример #23
0
        /// <summary>
        /// Selects an item in the combo-box with the specified item name.
        /// </summary>
        /// <param name="name">
        /// The name of the item to select.
        /// </param>
        public void SelectItem(string name)
        {
            this.Element.Click();

            this.VerifyElementsShown(this.comboBoxItemQuery, TimeSpan.FromSeconds(2));

            ReadOnlyCollection <AppiumWebElement> listElements = this.Element.FindElements(this.comboBoxItemQuery);

            AppiumWebElement item = listElements.FirstOrDefault(
                element => element.GetAttribute("Name").Equals(name, StringComparison.CurrentCultureIgnoreCase));

            item.Click();
        }
Пример #24
0
        public static void OpenFancyZonesSettings()
        {
            try
            {
                AppiumWebElement fzNavigationButton = settingsWindow.FindElementByName("FancyZones");
                Assert.IsNotNull(fzNavigationButton);

                fzNavigationButton.Click();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #25
0
 private static void ReturnToMainPage()
 {
     // Try to return to main page in case application is started in nested view
     try
     {
         AppiumWebElement backButton = null;
         do
         {
             backButton = AlarmClockSession.FindElementByAccessibilityId("Back");
             backButton.Click();
         }while (backButton != null);
     }
     catch { }
 }
Пример #26
0
        private void ClosePropertiesDialog(CloseAction action)
        {
            switch (action)
            {
            case CloseAction.OK:
                okButton.Click();
                break;

            case CloseAction.Cancel:
                cancelButton.Click();
                break;
            }

            Globals.WaitForTimeout();
        }
Пример #27
0
        static void SafeClick(AppiumWebElement element)
        {
            try
            {
                while (true)
                {
                    element.Click();

                    Thread.Sleep(TimeSpan.FromSeconds(1));
                }
            }
            catch (Exception)
            {
                // ignore
            }
        }
Пример #28
0
        public void CreateManyZones()
        {
            OpenCreatorWindow("Create new custom");
            ZoneCountTest(0, 0);

            const int        expectedZoneCount = 20;
            AppiumWebElement addButton         = editorWindow.FindElementByAccessibilityId("newZoneButton");

            for (int i = 0; i < expectedZoneCount; i++)
            {
                addButton.Click();
            }

            ZoneCountTest(expectedZoneCount, 0);
            SaveTest("canvas", "Custom Layout 1", expectedZoneCount);
        }
        public void ShowSpacingTest()
        {
            for (int i = 0; i < 2; ++i)
            {
                Assert.IsTrue(OpenEditor());

                AppiumWebElement spaceAroundSetting      = editorWindow.FindElementByAccessibilityId("spaceAroundSetting");
                bool             spaceAroundSettingValue = spaceAroundSetting.Selected;
                spaceAroundSetting.Click();

                editorWindow.FindElementByAccessibilityId("ApplyTemplateButton").Click();

                WaitSeconds(1);

                Assert.AreNotEqual(spaceAroundSettingValue, GetEditZonesSetting <bool>(editorShowSpacing));
            }
        }
Пример #30
0
 private static void ReturnToMainPage()
 {
     // Try to return to main page in case application is started in nested view
     try
     {
         AppiumWebElement backButton = null;
         do
         {
             backButton = NewsApp.FindElementByAccessibilityId("Back");
             backButton.Click();
         }while (backButton != null);
     }
     catch (Exception e)
     {
         Console.Write(e);
     }
 }