Пример #1
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);
        }
Пример #2
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);
            }
Пример #3
0
            public void DataGridKeyBoardShortcutsTest()
            {
                // Type a known text sequence, select, copy, and paste it three times
                AppiumWebElement firstIdCell = dataGrid.FindElementByName("Row 0").FindElementByName("Id Row 0");

                firstIdCell.SendKeys("789");
                firstIdCell.SendKeys(Keys.Control + "a" + Keys.Control);   // Select all using Ctrl + A keyboard shortcut
                firstIdCell.SendKeys(Keys.Control + "c" + Keys.Control);   // Copy using Ctrl + C keyboard shortcut
                firstIdCell.SendKeys(Keys.Control + "vvv" + Keys.Control); // Paste 3 times using Ctrl + V keyboard shortcut
                firstIdCell.SendKeys(Keys.Enter);
                Assert.AreEqual("789789789", firstIdCell.Text);
            }
        public void SpacingTestsInvalid()
        {
            Assert.IsTrue(OpenEditor());

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

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

            string[] invalidValues = { "!", "/", "<", "?", "D", "Z", "]", "m", "}", "1.5", "2,5" };

            string editorSpacingValue = GetEditZonesSetting <string>(editorSpacing);

            foreach (string value in invalidValues)
            {
                Assert.IsTrue(OpenEditor());

                AppiumWebElement paddingValue = editorWindow.FindElementByAccessibilityId("paddingValue");
                ClearText(paddingValue);
                paddingValue.SendKeys(value);

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

                Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting <bool>(editorShowSpacing));
                Assert.AreEqual(editorSpacingValue, GetEditZonesSetting <string>(editorSpacing));
            }
        }
        public void SpacingTestsValid()
        {
            Assert.IsTrue(OpenEditor());

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

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

            string[] validValues = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

            foreach (string editorSpacingValue in validValues)
            {
                Assert.IsTrue(OpenEditor());

                AppiumWebElement paddingValue = editorWindow.FindElementByAccessibilityId("paddingValue");
                ClearText(paddingValue);
                paddingValue.SendKeys(editorSpacingValue);

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

                Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting <bool>(editorShowSpacing));
                Assert.AreEqual(editorSpacingValue, GetEditZonesSetting <string>(editorSpacing));
            }
        }
Пример #6
0
        public void TradeMe_verify_logged_account()
        {
            AppiumWebElement TradeMe_Login = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginEmail");

            Assert.IsNotNull(TradeMe_Login);
            TradeMe_Login.SendKeys("*****@*****.**");
            AppiumWebElement TradeMe_Pwd = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginPassword");

            TradeMe_Pwd.SendKeys("yorks64");
            AppiumWebElement Login_Button = app.FindElementById("nz.co.trademe.trademe:id/buttonLogin");

            Login_Button.Tap(1, 1);
            WebDriverWait wait = new WebDriverWait(app, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/menuAccount")));
            AppiumWebElement account_icon = app.FindElementByAccessibilityId("Account");

            account_icon.Tap(1, 1);
            WebDriverWait wait1 = new WebDriverWait(app, TimeSpan.FromSeconds(30));

            wait1.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/buttonLogout")));
            AppiumWebElement account_name = app.FindElementById("nz.co.trademe.trademe:id/textViewAboutMemberUsername");

            Assert.AreEqual(account_name.Text, "sunjeet81");
            AppiumWebElement logout_button = app.FindElementById("nz.co.trademe.trademe:id/buttonLogout");

            logout_button.Tap(1, 1);
            WebDriverWait wait2 = new WebDriverWait(app, TimeSpan.FromSeconds(30));

            wait2.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/buttonDialogGenericConfirm")));
            AppiumWebElement confirm_button = app.FindElementByAccessibilityId("Confirm");

            confirm_button.Tap(1, 1);
            Assert.IsNotNull(app.FindElementByAccessibilityId("Login"));
        }
Пример #7
0
        public void TradeMe_verify_logged_in()
        {
            // Find the login input field
            AppiumWebElement TradeMe_Login = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginEmail");

            // key in your user name
            TradeMe_Login.SendKeys("*****@*****.**");
            // Find the password field
            AppiumWebElement TradeMe_Pwd = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginPassword");

            // key in the password
            TradeMe_Pwd.SendKeys("yorks64");
            // Find the login button
            AppiumWebElement Login_Button = app.FindElementById("nz.co.trademe.trademe:id/buttonLogin");

            // Tap the login button
            Login_Button.Tap(1, 1);
            // Wait for the account menu item to be displayed
            WebDriverWait wait = new WebDriverWait(app, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/menuAccount")));
            // Find icon for my account
            AppiumWebElement account_icon = app.FindElementByAccessibilityId("Account");

            // tap the icon
            account_icon.Tap(1, 1);
            // confirm that the logout button is visible, this is in turn ensure that the user name isbeing displayed
            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/buttonLogout")));
            // find and assert on the text of the user name
            AppiumWebElement account_name = app.FindElementById("nz.co.trademe.trademe:id/textViewAboutMemberUsername");

            Assert.AreEqual(account_name.Text, "sunjeet81");
        }
        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()}");
        }
Пример #9
0
        /// <summary>
        /// Do multiple select
        /// Click on all row.
        /// </summary>
        public void SelectAllRows()
        {
            AppiumWebElement cell = _table.FindElementByName("Row " + 1);

            SetCellVisible(cell);
            cell.ClickAction();
            cell.SendKeys(Keys.Control + "a");
        }
Пример #10
0
        public void AppiumDriverMethodsTestCase()
        {
            // Using appium extension methods
            AppiumWebElement el = driver.FindElements(ByAndroidUIAutomator.(UiSelector().enabled(true)));

            el.SendKeys("abc");
            Assert.AreEqual(el.Text, "abc");
        }
Пример #11
0
 /// <summary>
 /// Sends the keys to the element defined by AppiumWebElement.
 /// </summary>
 /// <param name="element">Element.</param>
 /// <param name="keysToSend">Keys to send.</param>
 public static void SendKeys(AppiumWebElement element, String keysToSend)
 {
     try
     {
         element.SendKeys(keysToSend);
     }
     catch (Exception e)
     {
         PrintException(e);
     }
 }
Пример #12
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);
            }
        }
Пример #13
0
        public void TestCreateSimpleTask()
        {
            driver.FindElement(By.Id("btn_welcome_log_in")).Click();
            // *** Google Play Services Activity ***
            driver.FindElement(By.Id("button1")).Click();

            // *** Login Activity ****
            driver.FindElement(By.Id("log_in_email")).SendKeys(EMAIL);
            driver.FindElementById("log_in_password").SendKeys(PASSWORD);
            driver.FindElementById("btn_log_in").Click();

            // *** Google Play Services Activity ***
            driver.FindElementById("button1").Click();

            // *** Goolge Play services in not supported ***
            //driver.FindElementById("button1").Click();

            // Clicking on the Today menu item
            driver.FindElement(By.XPath("//android.widget.TextView[@text='Today']")).Click();

            // Creating a new task
            driver.FindElementById("fab").Click();
            String           taskName = "Automated task" + DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            AppiumWebElement message  = driver.FindElementById("message");

            message.SendKeys(taskName + " #work");
            driver.FindElementById("button1").Click();

            // Going back
            driver.FindElementById("action_mode_close_button").Click();



            // Searching for the newly created item
            ReadOnlyCollection <AppiumWebElement> items = driver.FindElements(By.XPath("//android.widget.RelativeLayout[@resource-id='com.todoist:id/item']/android.widget.TextView"));
            Boolean found = false;

            foreach (AppiumWebElement item in items)
            {
                Console.Write("Item: " + item.Text);
                if (item.Text.Equals(taskName))
                {
                    found = true;
                    break;
                }
            }
            Assert.IsTrue(found, "Item was not created");


            Thread.Sleep(1000);
        }
        public void SpacingTestLargeValue()
        {
            Assert.IsTrue(OpenEditor());
            editorWindow.FindElementByName("Grid").Click();

            AppiumWebElement paddingValue = editorWindow.FindElementByAccessibilityId("paddingValue");

            ClearText(paddingValue);
            paddingValue.SendKeys("1000");

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

            try
            {
                Assert.IsTrue(OpenEditor());
            }
            catch { }

            Assert.AreNotEqual(editorWindow, null, "Editor Zones Window is not starting after setting large padding value");
        }
Пример #15
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");
        }
Пример #16
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"));
    }
Пример #17
0
        public void TestMethod2()
        {
            AppiumDriver <AndroidElement> driver;
            DesiredCapabilities           cap = new DesiredCapabilities();

            cap.SetCapability("deviceName", "donatello");
            cap.SetCapability(AndroidMobileCapabilityType.AppPackage, "com.android.calculator2");
            cap.SetCapability(MobileCapabilityType.BrowserName, "Browser");
            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);

            driver.Url = "http://www.google.com";

            //do the UI operation of search in google
            AppiumWebElement txtsearch = driver.FindElementByName("q");

            txtsearch.SendKeys("naveen tirumalasetty");
            driver.FindElementByName("btnG").Click();
            driver.CloseApp();
        }
 private void ClearText(AppiumWebElement windowsElement)
 {
     windowsElement.SendKeys(Keys.Home);
     windowsElement.SendKeys(Keys.Control + Keys.Delete);
 }