Esempio n. 1
0
        public void RunUnitTests()
        {
            //app.Repl();
            var appName = GetAppName();

            Console.WriteLine(appName);

            app.Tap(c => c.Id("RunTestsButton"));

            app.WaitFor(() => app.Query(a => a.Id("ResultsResult")).Single().Text != string.Empty);

            var resultLabel = app.Query(a => a.Id("ResultsResult")).Single();

            Console.WriteLine(resultLabel.Text);

            Console.WriteLine(string.Empty);

            Console.WriteLine("Test Results:");

            app.Tap(c => c.Id("TestSuiteListView"));

            app.WaitFor(() => app.Query(a => a.Id("ResultsId")).Count() >= 1 && !app.Query(a => a.Id("ResultsId")).Any(b => b.Text.Contains("appName")));

            Assert.AreEqual("Passed", resultLabel.Text);
        }
Esempio n. 2
0
        public void Login()
        {
            Thread.Sleep(10000);
            app.Tap("Email");
            app.EnterText(EmailFinal);
            app.Tap("Password");
            app.EnterText("magicA123");
            app.Tap(x => x.Id("signInButton"));
            Thread.Sleep(15000);

            var isAddCode = app.Query(x => x.Id("pop_up_title")).Any();

            if (isAddCode == true)
            {
                app.Flash(x => x.Id("dialogAddCodeBtn"));
                app.Tap(x => x.Id("notNowTextView"));
            }
            ProfileUpdate();
            BabyUpdate();
            History();
            PamperReward();
            GetMorePoints();
            ParentsHub();
            ShowNotification();
        }
Esempio n. 3
0
        public void AfterEachTest()
        {
            // Start the application
            app = ConfigureApp.Android.StartApp();

            // Delete recently created city if still existing
            // Depending on your test configuration and environment, ConfigureApp.Android.StartApp(); sometimes
            // deployes a complete new package of the app. In this case, no cleanup work is needed.
            app.WaitForElement(x => x.Id("textView1"));
            var city = app.Query(x => x.Text(testCityName)).FirstOrDefault();
            if (city != null)
            {
                // Delete the recently created city
                app.Tap(x => x.Text(testCityName));
                app.WaitForElement(x => x.Class("OverflowMenuButton"));
                app.Tap(x => x.Class("OverflowMenuButton"));
                app.Tap(x => x.Class("TextView").Index(0)); // Edit button

                app.WaitForElement(x => x.Id("action_delete_city"), "Delete city button never appeared...");
                app.Tap(x => x.Id("action_delete_city"));
                app.Tap(x => x.Id("button1"));

                // Check if city has been deleted successfully
                var results = app.Query(x => x.Text(testCityName));
                Assert.IsFalse(results.Any());
            }
        }
        public void SpecFlow_VerkenHoofdscherm()
        {
            int lengte1 = 0;
            int lengte2 = 0;

            app.WaitForElement(c => c.Id("action_bar"));
            app.Flash(c => c.Id("plusButton"));
            app.Tap(c => c.Id("plusButton"));
            app.Tap(c => c.Id("plusButton"));
            app.Tap(c => c.Id("plusButton"));
            app.Flash(c => c.Id("minButton"));
            app.Tap(c => c.Id("minButton"));
            app.Tap(c => c.Id("minButton"));
            app.Flash(c => c.Id("route1Button"));
            app.Tap(c => c.Id("route1Button"));
            var resultlengte1 = app.Query(c => c.Id("lengte").Invoke("getText"));

            if (resultlengte1[0].ToString() != null)
            {
                lengte1 = Int32.Parse(resultlengte1[0].ToString());
            }
            app.Flash(c => c.Id("route2Button"));
            app.Tap(c => c.Id("route2Button"));
            app.Flash(c => c.Id("lengte"));
            var resultlengte2 = app.Query(c => c.Id("lengte").Invoke("getText"));

            if (resultlengte2[0].ToString() != null)
            {
                lengte2 = Int32.Parse(resultlengte2[0].ToString());
            }

            //bij 11 punten is de lengte soms gelijk
            Assert.GreaterOrEqual(lengte2, lengte1);
        }
        public void TestCheckActionBarTitle()
        {
            // Get the text of action bar
            var result = app.Query(c => c.Class("TextView").Text("TextSwitcher"));

            // Check for the text is not null
            Assert.NotNull(result);
        }
Esempio n. 6
0
        public void IsNewestScreenPresented()
        {
            app.WaitForElement(c => c.Class("FormsTextView").Text("Sidste 7 dage:"));
            //Query for TextView where the Text property is as below
            var newestWithDraw = app.Query(c => c.Class("TextView").Text("Nyeste tilbagetrækninger"));

            //I would only expect 1 TextView, if there are more its a bug.
            Assert.AreEqual(1, newestWithDraw.Count());
        }
Esempio n. 7
0
        public void ThenToontHetSchermKnopen(int aantalverwacht)
        {
            var resultaantal = app.Query(c => c.Id("nknopen").Invoke("getText"));

            if (resultaantal[0].ToString() != null)
            {
                int aantalgetoond = Int32.Parse(resultaantal[0].ToString());
                Assert.AreEqual(aantalgetoond, aantalverwacht);
            }
        }
Esempio n. 8
0
        public string[] all()
        {
            var qr = app.Query(c => c.All()).Where(r).Select(this.res).OrderBy(e => e).ToArray();

            var text = app.Query(c => c.All()).Where(e => !string.IsNullOrEmpty(e.Text)).Select(this.res).OrderBy(e => e).ToArray();

            Console.Out.WriteLine("elements " + qr.Length + " text " + text.Length);

            return(qr);
        }
Esempio n. 9
0
        public void VerifyNewcomersInstruction()
        {
            do
            {
                app.Tap("nextView");
            }while (app.Query(x => x.Marked("nextView").Invoke("getText"))[0].ToString() != "Перейти в каталог");
            app.Tap("nextView");
            app.WaitForElement(x => x.Marked("name"));
            string result = app.Query(x => x.Marked("name").Invoke("getText"))[0].ToString();

            Assert.AreEqual("Электроника", result);
        }
Esempio n. 10
0
        public void TestAddShortcutSuccess()
        {
            var website = "http://www.xamarin.com";

            AddShortcut(website);

            // wait for the list item
            app.WaitForElement(c => c.Id("line1"));
            var itemText = app.Query(c => c.Id("line1").Invoke("getText").Value <string>());

            Assert.NotNull(itemText);
            Assert.AreEqual(itemText[0], website);
        }
Esempio n. 11
0
        /// <summary>
        /// Incrementally scrolls down until the desired elements are found
        /// </summary>
        public static AppResult[] ScrollDownEnough(this AndroidApp app, Func <AppQuery, AppQuery> lambda, string screenshot = null)
        {
            AppResult rootView = null;
            int       count    = 0;
            int       maxTries = 20;

            AppResult[] lastTry;
            while (count < maxTries)
            {
                lastTry = app.Query(lambda);

                if (lastTry.Any())
                {
                    if (screenshot != null)
                    {
                        app.Screenshot(screenshot);
                    }

                    return(lastTry);
                }

                if (rootView == null)
                {
                    rootView = app.Query(e => e.All()).FirstOrDefault();

                    if (rootView == null)
                    {
                        throw new Exception("Unable to get root view");
                    }
                }

                //Will try to scroll +/-100 from the vertical center point
                float gap = 100;

                //Take into account where the screen is not large and the gap would be too big
                if (rootView.Rect.Height < gap * 2)
                {
                    gap = rootView.Rect.Height / 4;
                }

                app.DragCoordinates(rootView.Rect.CenterX, rootView.Rect.CenterY + gap, rootView.Rect.CenterX, rootView.Rect.CenterY - gap);
                count++;
            }

            if (count == maxTries)
            {
                throw new Exception("Unable to scroll down to find element");
            }

            return(new AppResult[0]);
        }
Esempio n. 12
0
        public void TamperedEnabled_CappuccinoTest()
        {
            app.Tap(x => x.Marked("DrinkType"));
            app.Screenshot("Tapped Drink Type");

            app.Tap(x => x.Marked("Cappuccino"));
            app.Screenshot("Tapped on Cappuccino");

            app.DismissKeyboard();

            app.Screenshot("Dismissed Keyboard");
            var result = app.Query("Tamered").First();

            Assert.IsTrue(result.Enabled, "Tampered is enabled");
        }
Esempio n. 13
0
        public void CollectSymbols()
        {
            _app.Tap(q => q.Id("btnUpload"));
            var totalWaitTimeSeconds = 40 * 60;
            var retryCounter         = 200;
            var iterationTimeout     = TimeSpan.FromSeconds(totalWaitTimeSeconds / retryCounter);

            while (true)
            {
                try
                {
                    _app.WaitForElement(query => query.Id("done_text"), timeout: iterationTimeout);
                    _app.Screenshot("💯");
                    break;
                }
                catch (Exception e) when(e.InnerException is TimeoutException)
                {
                    if (--retryCounter == 0)
                    {
                        _app.Screenshot("Timeout");
                        throw;
                    }

                    // Check if it failed
                    var result = _app.Query(p => p.Id("alertTitle"));

                    if (result?.Any() == true)
                    {
                        _app.Screenshot("Error");
                        throw new Exception("Error modal found, app errored.");
                    }
                }
            }
        }
Esempio n. 14
0
 public void BlurImage()
 {
     app.Screenshot("Launch");
     app.WaitForElement(q => q.Id("seekBar1"));
     app.Query(q => q.Id("seekBar1").Invoke("setProgress", 15));
     app.Screenshot("Blurred Image");
 }
Esempio n. 15
0
 public void TextView_Shows_Up_When_Button_Clicked()
 {
     app.Tap(c => c.Id("buttonShow"));
     app.Screenshot("Button Pressed");
     AppResult[] result = app.Query(c => c.Id("textViewShow"));
     Assert.IsTrue(result.Any(), "TextView not displayed");
 }
Esempio n. 16
0
        public string[] CountTopics()
        {
            var firstElements = app.Query(c => c.Id(nextButton)).Select(x => x.Text).ToList();

            app.ScrollDown();
            var secondElements = app.Query(c => c.Id(nextButton)).Select(x => x.Text).ToList();

            foreach (var s in secondElements)
            {
                firstElements.Add(s);
            }

            var elements = firstElements.Distinct().ToArray();

            return(elements);
        }
Esempio n. 17
0
 public void AppDidLaunch()
 {
     app.WaitForElement(c => c.Id("fab"));
     app.Tap(c => c.Id("fab"));
     Assert.AreNotEqual("ERROR!", app.Query(c => c.Id("textView1"))[0].Text);
     app.Screenshot("App launched");
 }
Esempio n. 18
0
        public void TapRandomButtonsTest()
        {
            var rand = new Random();

            for (var i = 0; i < 10; i++)
            {
                var buttons = _app.Query(c => c.Button()).ToArray();

                if (!buttons.Any())
                {
                    break;
                }

                try
                {
                    _app.Tap(c => c.Button().Index(rand.Next(0, buttons.Length - 1)));
                }
                catch
                {
                    // Fail silently, this is probably due to the number of buttons on the page being reduced between
                    // the app.Query() and the app.Tap().
                }

                var word = i == 0 ? "a" : "another";

                _app.Screenshot($"Tapped {word} random button");

                Thread.Sleep(3000);  // This should allow any animations to complete in most cases
            }
        }
Esempio n. 19
0
    public void BasicFahrenheitSetup()
    {
        // Let something load before proceeding
        app.WaitForElement(x => x.Marked("JunctionTemperatureLabel"));
        app.Screenshot("Initial launch");

        app.SetSliderValue(x => x.Class("FormsSeekBar").Index(0), 250);
        app.SetSliderValue(x => x.Class("FormsSeekBar").Index(1), 208);
        app.ScrollDown();               // Might be necessary on small screens
        app.SetSliderValue(x => x.Class("FormsSeekBar").Index(2), 50);
        app.Screenshot("Sliders set for 5V from 12V at 0.5A");

        app.ScrollUp();
        app.SetOrientationLandscape();
        app.Screenshot("Setup in landscape");

        app.SetOrientationPortrait();
        app.Tap(x => x.Marked("OK"));
        app.Screenshot("Opened settings");

        app.Tap(x => x.Text("Fahrenheit (°F)"));
        app.Screenshot("Tapped on view with class: FormsTextView");

        app.SwipeRightToLeft();
        app.Screenshot("Swiped left");

        app.WaitForElement(x => x.Marked("JunctionTemperatureLabel"));
        var temperatureF = app.Query(x => x.Marked("JunctionTemperatureLabel"));

        Assert.IsTrue(temperatureF[0].Text.Equals("JUNCTION TEMP: 222.1 ˚F"));
    }
Esempio n. 20
0
        public void numberToShort()
        {
            app.WaitForElement(invoerveldcardnummer);
            app.Screenshot("After starting application");
            app.EnterText(invoerveldcardnummer, shortnumber);

            app.WaitForElement(e => e.Text(shortnumber), "number not in textfield");
            app.Screenshot("number entred");
            app.Tap(validatieknop);

            app.WaitForElement(errormessageappears, "no error message");
            app.Screenshot("After doing the validation");
            var toshort = app.Query(textistoshortmessage).SingleOrDefault();

            Assert.IsNotNull(toshort);
        }
Esempio n. 21
0
        public void RunBenchmarkHelper(string benchmark)
        {
            var assembly = Assembly.GetExecutingAssembly();

            using (Stream stream = assembly.GetManifestResourceStream("AndroidAgent.UITests.params.json")) {
                using (StreamReader reader = new StreamReader(stream)) {
                    dynamic json          = JsonConvert.DeserializeObject(reader.ReadToEnd());
                    string  githubAPIKey  = json.githubAPIKey;
                    string  httpAPITokens = json.httpAPITokens;
                    string  machineName   = json.machineName;
                    string  runSetId      = json.runSetId;
                    string  configName    = json.configName;

                    app.Screenshot("init");

                    clearAndSetTextField("benchmark", benchmark);
                    clearAndSetTextField("githubAPIKey", githubAPIKey);
                    clearAndSetTextField("httpAPITokens", httpAPITokens);
                    clearAndSetTextField("machineName", machineName);
                    clearAndSetTextField("runSetId", runSetId);
                    clearAndSetTextField("configName", configName);

                    app.Tap(c => c.Marked("myButton"));
                    app.Screenshot("after tap");
                    app.WaitForNoElement(c => c.Marked("myButton").Text("running"), "Benchmark is taking too long", TimeSpan.FromMinutes(179));
                    Assert.AreEqual(app.Query(c => c.Marked("myButton")).First().Text, "start");
                    app.Screenshot("after benchmark");
                }
            }
        }
Esempio n. 22
0
        public void VerticalPhrases()
        {
            app.Tap(x => x.Class("TextView").Index(1));
            app.Tap(x => x.Class("TextView").Index(6));
            app.Tap(x => x.Class("TextView").Index(11));
            app.Tap(x => x.Class("TextView").Index(16));
            app.Screenshot("4 in a column are selected");
            app.Tap(x => x.Class("TextView").Index(21));

            app.WaitForElement(x => x.Id("alertTitle"));

            var results = app.Query(x => x.Id("alertTitle"));

            Assert.AreEqual("You won, congratulations!", results [0].Text);
            app.Screenshot("A Congratulating dialog should appear");
        }
Esempio n. 23
0
 public void Toast_Displayed_If_CallButton_Pressed_With_EmptyTextBox()
 {
     app.Screenshot("App Started");
     app.Tap(c => c.Id("CallButton"));
     app.Screenshot("Call Button Pressed");
     AppResult[] result = app.Query(c => c.Marked("Please provide number"));
     Assert.IsTrue(result.Any(), "Toast not displayed");
 }
Esempio n. 24
0
        public void LaunchingShouldDisplayList()
        {
            app.Screenshot("Launch");

            var items = app.Query(q => q.Id("text1"));

            Assert.Greater(items.Count(), 0, "No List Items Found");
        }
Esempio n. 25
0
        public string CountResults()
        {
            app.WaitForElement(_resultCount);
            var countOfResults = app.Query(_resultCount).Select(x => x.Text).First();
            var result         = Regex.Match(countOfResults, @"\D+ (\d+) \D+");
            var count          = result.Groups.Cast <Group>().Select(x => x.Value).Skip(1).First();

            return(count);
        }
Esempio n. 26
0
        public void AppLaunches()
        {
            app.EnterText(valorUm, "10");
            app.EnterText(valorDois, "10");

            app.Tap(btn);
            AppResult[] result = app.Query(resultado);

            Assert.AreEqual("20", result[0].Text);
        }
Esempio n. 27
0
        public void ClickingButtonTwiceShouldChangeItsLabel()
        {
            Func <AppQuery, AppQuery> MyButton = c => c.Button("myButton");

            app.Tap(MyButton);
            app.Tap(MyButton);
            AppResult[] results = app.Query(MyButton);
            app.Screenshot("Button clicked twice.");

            Assert.AreEqual("2 clicks!", results[0].Text);
        }
        public static void LogToDevice(this AndroidApp app, Func <AppQuery, AppQuery> lambda = null)
        {
            if (lambda == null)
            {
                lambda = e => e.All();
            }

            var results = app.Query(lambda);

            app.LogToDevice(results.ToString(true));
        }
Esempio n. 29
0
 public void App_Login_login()
 {
     app.EnterText("et_login", "Altamir");
     app.EnterText("et_pass", "12345");
     app.DismissKeyboard();
     app.Tap("bt_logar");
     app.WaitFor(() =>
                 app.Query(e => e.Id("tx_result"))
                 .First().Enabled, "Wait for page",
                 TimeSpan.FromSeconds(20));
 }
Esempio n. 30
0
        public void Teste_Xamarin_Android()
        {
            //app.Repl();
            app.EnterText(valorUm, "10");
            app.EnterText(valorDois, "10");

            app.Tap(btn);
            AppResult[] result = app.Query(resultado);

            Assert.AreEqual("20", result[0].Text);
        }
        public void BeforeEachTest()
        {
            app = ConfigureApp.Android.StartApp ();
            app.Screenshot ("Given the app is loaded");
            app.Tap (x => x.Button ("btn_play"));

            app.WaitForElement (x => x.Id ("tv_bingoItem"));

            var results = app.Query (x => x.Id ("tv_bingoItem"));
            Assert.AreEqual (25, results.Length);
            app.Screenshot ("25 items should be shown");
        }
Esempio n. 32
0
        string GetTitle(int timeoutInSeconds = 60)
        {
            App.WaitForElement(_pageTitleText, "Could Not Retrieve Page Title", TimeSpan.FromSeconds(timeoutInSeconds));

            var titleQuery = App switch
            {
                iOSApp iosApp => iosApp.Query(x => x.Class("UILabel").Marked(_pageTitleText)),
                AndroidApp androidApp => androidApp.Query(x => x.Class("AppCompatTextView").Marked(_pageTitleText)),
                _ => throw new NotSupportedException(),
            };

            return(titleQuery.First().Text);
        }
Esempio n. 33
0
        public void BeforeEachTest()
        {
            // Start the application
            app = ConfigureApp.Android.StartApp();

            // Create a new city
            app.WaitForElement(x => x.Id("action_add_city"));
            app.Tap(x => x.Id("action_add_city"));
            app.EnterText(x => x.Id("addEditCityName"), testCityName);
            app.EnterText(x => x.Id("addEditCityZip"), testCityZip);
            app.Tap(x => x.Id("action_add_city_confirm"));

            // Check if city has been created successfully
            var results = app.Query(x => x.Text(testCityName));
            Assert.IsTrue(results.Any());
        }
        public virtual void BeforeEachTest()
        {
            app = AppInitializer.StartApp();

            Thread.Sleep(TimeSpan.FromSeconds(5));

            if (app.Query("SIGN IN").Any())
            {
                new SplashScreenPage(app)
                    .ExitSplashScreen();
            }

            //waiting for next screen to load
            Thread.Sleep(TimeSpan.FromSeconds(5));

            app.Screenshot("On Home Page");
        }