コード例 #1
0
        public void MultiActionTestCase()
        {
            IOSDriver <IWebElement> driver  = new IOSDriver <IWebElement>(defaultUri, capabilities);
            RequestProcessor        re      = setupMultiAction();
            IWebElement             element = driver.FindElementByIosUIAutomation(".elements()");

            MultiAction m = new MultiAction(driver);

            m.Perform();
            Assert.AreEqual(re.inputData, "");

            TouchAction a1 = new TouchAction(driver);

            a1
            .Press(element, 100, 100)
            .Wait(1000)
            .Release();
            m.Add(a1);
            m.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[[{\"action\":\"press\",\"options\":{\"element\":\"5\",\"x\":100,\"y\":100}},{\"action\":\"wait\",\"options\":{\"ms\":1000}},{\"action\":\"release\"}]]}");

            TouchAction a2 = new TouchAction(driver);

            a2
            .Tap(100, 100)
            .MoveTo(element);
            m.Add(a2);
            m.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[[{\"action\":\"press\",\"options\":{\"element\":\"5\",\"x\":100,\"y\":100}},{\"action\":\"wait\",\"options\":{\"ms\":1000}},{\"action\":\"release\"}],[{\"action\":\"tap\",\"options\":{\"x\":100,\"y\":100}},{\"action\":\"moveTo\",\"options\":{\"element\":\"5\"}}]]}");
        }
コード例 #2
0
        public void MoveToTestCase()
        {
            IOSDriver <IWebElement> driver  = new IOSDriver <IWebElement>(defaultUri, capabilities);
            RequestProcessor        re      = setupTouchAction();
            IWebElement             element = driver.FindElementByIosUIAutomation(".elements()");

            ITouchAction a;

            a = new TouchAction(driver)
                .MoveTo(element, 50, 75);
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"element\":\"5\",\"x\":50,\"y\":75}}]}");

            a = new TouchAction(driver)
                .MoveTo(element, 0.5, 75);
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"element\":\"5\",\"x\":0.5,\"y\":75}}]}");

            a = new TouchAction(driver)
                .MoveTo(0.5, 75);
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"x\":0.5,\"y\":75}}]}");

            a = new TouchAction(driver)
                .MoveTo(element);
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"element\":\"5\"}}]}");
        }
コード例 #3
0
        public void FromElementTestCase()
        {
            IOSDriver <IWebElement> driver = new IOSDriver <IWebElement>(defaultUri, capabilities);

            server.respondTo("POST", "/element", new Dictionary <string, object>  {
                
                             {
                    "ELEMENT", '5'
                } 

            });
            IOSElement element = (IOSElement)driver.FindElementByIosUIAutomation(".elements()");

            server.clear();
            server.respondTo("POST", "/element/5/element", new Dictionary <string, object>  {
                
                           {
                    "ELEMENT", '6'
                } 

            });
            element.FindElementByIosUIAutomation(".elements()");
            server.clear();
            List <object> results = new List <object>();

            results.Add(new Dictionary <string, object> {
                { "ELEMENT", "4" }
            });
            server.respondTo("POST", "/element/5/elements", results);
            element.FindElementsByIosUIAutomation(".elements()");
        }
コード例 #4
0
        public void SetImmediateValueTestCase()
        {
            IOSDriver driver = new IOSDriver(defaultUri, capabilities);

            server.respondTo("POST", "/element", new Dictionary <string, object>  {
                { "ELEMENT", '5' }
            });
            AppiumWebElement element = (AppiumWebElement)driver.FindElementByIosUIAutomation(".elements()");

            server.clear();
            server.respondTo("POST", "/appium/element/5/value", null);
            element.SetImmediateValue("123");
        }
コード例 #5
0
        public void FindElementByIosUIAutomationTestCase()
        {
            IOSDriver driver = new IOSDriver(defaultUri, capabilities);

            server.respondTo("POST", "/element", new Dictionary <string, object>  {
                { "ELEMENT", '5' }
            });
            IWebElement element = driver.FindElementByIosUIAutomation(".elements()");

            server.clear();
            server.respondTo("GET", "/element/5/attribute/id", "1234");
            element.GetAttribute("id");
        }
コード例 #6
0
ファイル: IosSimpleTest.cs プロジェクト: stvenfor/sample-code
        public void ComputeSumTestCase()
        {
            // fill form with random data
            int sumIn = Populate();

            // compute and check the sum
            driver.FindElementByAccessibilityId("ComputeSumButton").Click();
            Thread.Sleep(1000);

            IWebElement sumEl  = driver.FindElementByIosUIAutomation(".elements().withName(\"Answer\")");
            int         sumOut = Convert.ToInt32(sumEl.Text);

            Assert.AreEqual(sumIn, sumOut);
        }
コード例 #7
0
        public void ElementRotateTestCase()
        {
            IOSDriver driver = new IOSDriver(defaultUri, capabilities);

            server.respondTo("POST", "/element", new Dictionary <string, object>  {
                { "ELEMENT", '5' }
            });
            AppiumWebElement element = (AppiumWebElement)driver.FindElementByIosUIAutomation(".elements()");

            server.clear();
            server.respondTo("POST", "/appium/device/rotate", null);
            Dictionary <string, int> parameters = new Dictionary <string, int> {
                { "x", 114 },
                { "y", 198 }, { "duration", 5 }, { "radius", 3 }, { "rotation", 220 }, { "touchCount", 2 }
            };

            element.Rotate(parameters);
        }
コード例 #8
0
        public virtual bool HasLabel(string text, CompareType compareType, int timeoutSecs)
        {
            var compareStr = "";

            switch (compareType)
            {
            case CompareType.StartsWith:
                compareStr = "BEGINSWITH";
                break;

            case CompareType.EndsWith:
                compareStr = "ENDSWITH";
                break;

            case CompareType.Equals:
                compareStr = "==";
                break;

            case CompareType.Matching:
                compareStr = "MATCHES";
                break;

            case CompareType.Containing:
                compareStr = "CONTAINS";
                break;

            default:
                throw new ArgumentException("Unsupported compare type: " + compareType);
            }

            var escapedText = text.Replace(@"\", "")   // do not allow backslash chars
                              .Replace(@"'", @"\\'")   // replace single quotes with escaped backslash + single quote
                              .Replace(@"""", @"\"""); // replace with unescaped backslash (due to delimited by single quotes) + double quote
            var selector = String.Format(@".getFirstWithPredicate(""ANY staticTexts.label {0} '{1}'"")", compareStr, escapedText);

            var element = Driver.FindElementByIosUIAutomation(selector, timeoutSecs);

            return(element != null);
        }
コード例 #9
0
 public override IOSElement FindElement(IOSDriver <IOSElement> searchContext)
 {
     return(searchContext.FindElementByIosUIAutomation(Value));
 }
コード例 #10
0
        public void AppiumTestMethod()
        {
            //Write your test here
            try
            {
                // write your code here
                // press Don't Allow button on Notifications screen if it appears
                try
                {
                    //IWebElement alert = driver.FindElementByXPath("//UIAAlert[contains(@name, \"Send You Notifications\")]");
                    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2));
                    driver.FindElementByName("Don't Allow").Click();
                }
                catch (NoSuchElementException n1)
                {
                    Trace.WriteLine("No notifications popup, just plow ahead!");
                }

                // press OK button on Welcome popup if it appears
                try
                {
                    IWebElement header = driver.FindElementByName("Welcome");
                    IWebElement okBtn  = driver.FindElementByName("OK");
                    okBtn.Click();
                }
                catch (NoSuchElementException n1)
                {
                    Trace.WriteLine("No welcome popup, just plow ahead!");
                }

                // Press "New Note" button (on right end of header)
                driver.FindElementByName("add os7").Click();

                // Verify that arrive at the New Task screen
                try
                {
                    IWebElement nTask = driver.FindElementByName("New Task");
                }
                catch (NoSuchElementException n)
                {
                    Trace.WriteLine("Did not reach New Task window!");
                    throw n;
                }

                // Enter a title for the new task
                IWebElement title = driver.FindElementByIosUIAutomation("UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0]");
                title.SendKeys("Prepare the script for Native Application");

                // Enter text into the Details field
                IWebElement detail = driver.FindElementByIosUIAutomation(".textFields()[1]");
                detail.SendKeys("Select an application, upload, and use Object Spy");

                // Click "Done" to go to next stage
                driver.FindElementByName("Done").Click();

                // Click on the Due Date field to select the due date
                try
                {
                    driver.FindElementByXPath("//UIAStaticText[@name='Due Date']").Click();
                }
                catch (NoSuchElementException n)
                {
                    Trace.WriteLine("Not showing second stage display!");
                    throw n;
                }
                // select that task is due next week
                driver.FindElementByName("+1 Week").Click();

                // Click "Done" to complete the task definition
                driver.FindElementByName("Done").Click();

                // Verify that task is listed
                try
                {
                    IWebElement nTask = driver.FindElementByName("Prepare the script for Native Application");
                }
                catch (NoSuchElementException n)
                {
                    Trace.WriteLine("The task is not listed!");
                    throw n;
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Failed due to an exception:" + e.Message);
            }
        }