Ejemplo n.º 1
0
        public void GetBottomRight_Driver()
        {
            var response = FlutterDriver.GetBottomRight(Control);

            response.Dx.Should().BeGreaterThan(0);
            response.Dy.Should().BeGreaterThan(0);
        }
Ejemplo n.º 2
0
        public void ByText()
        {
            // Text
            FlutterDriver.Click(FlutterBy.Text("FUT: FlutterBy.Text (Increment 1)"));

            AssertCounterIs("1", because: "we pressed the Add+1 button");
        }
Ejemplo n.º 3
0
        public void GetCenter_Driver()
        {
            var response = FlutterDriver.GetCenter(Control);

            response.Dx.Should().BeGreaterThan(0);
            response.Dy.Should().BeGreaterThan(0);
        }
Ejemplo n.º 4
0
        public void GetPosition_ValuesAreCongruent_ByDriver()
        {
            // If other tests fail in this class: fix those first.
            var topLeft     = FlutterDriver.GetTopLeft(Control);
            var topRight    = FlutterDriver.GetTopRight(Control);
            var bottomLeft  = FlutterDriver.GetBottomLeft(Control);
            var bottomRight = FlutterDriver.GetBottomRight(Control);
            var center      = FlutterDriver.GetCenter(Control);

            // The bounding box is a square
            topLeft.Dx.Should().Be(bottomLeft.Dx, because: "the left boundary is a straight vertical line");
            topRight.Dx.Should().Be(bottomRight.Dx, because: "the right boundary is a straiight vertical line");

            topLeft.Dy.Should().Be(topRight.Dy, because: "the top boundary is a straight horizontal line");
            bottomLeft.Dy.Should().Be(bottomRight.Dy, because: "the bottom boundary is a straight horizontal line");

            topLeft.Dx.Should().BeLessThan(center.Dx, "thats just the way a square rocks and rolls");
            topLeft.Dy.Should().BeLessThan(center.Dy, "thats just the way a square rocks and rolls");
            bottomLeft.Dx.Should().BeLessThan(center.Dx, "thats just the way a square rocks and rolls");
            bottomLeft.Dy.Should().BeGreaterThan(center.Dy, "thats just the way a square rocks and rolls (using (X,Y) == (0,0) coords");

            topRight.Dx.Should().BeGreaterThan(center.Dx, "thats just the way a square rocks and rolls");
            topRight.Dy.Should().BeLessThan(center.Dy, "thats just the way a square rocks and rolls");
            bottomRight.Dx.Should().BeGreaterThan(center.Dx, "thats just the way a square rocks and rolls");
            bottomRight.Dy.Should().BeGreaterThan(center.Dy, "thats just the way a square rocks and rolls");
        }
Ejemplo n.º 5
0
        public void ByValueKey()
        {
            // Text
            FlutterDriver.Click(FlutterBy.ValueKey("FUT: FlutterBy.ValueKey (Increment 2)"));

            AssertCounterIs("2", because: "we pressed the Add+2 button");
        }
Ejemplo n.º 6
0
        public void GetTopleft_Driver()
        {
            var response = FlutterDriver.GetTopLeft(Control);

            response.Dx.Should().BeGreaterThan(0);
            response.Dy.Should().BeGreaterThan(0);
        }
Ejemplo n.º 7
0
        public void ByTooltip()
        {
            // Text
            FlutterDriver.Click(FlutterBy.Tooltip("FUT: FlutterBy.Tooltip (Increment 3)"));

            AssertCounterIs("3", because: "we pressed the Add+3 button");
        }
Ejemplo n.º 8
0
        public void ByType()
        {
            // Text
            FlutterDriver.Click(FlutterBy.Type("FlatButton"));

            AssertCounterIs("-4", because: "we pressed the Add button (Flat Button)");
        }
Ejemplo n.º 9
0
        public void BySemanticsLabel()
        {
            // Text
            FlutterDriver.Click(FlutterBy.SemanticsLabel("FUT: FlutterBy.SemanticsLabel (Increment 4)"));

            AssertCounterIs("4", because: "we pressed the Semantics Label button");
        }
Ejemplo n.º 10
0
        public void ShortAndLongPress()
        {
            var touchActions = new FlutterTouchActions().Tap(TapControl).LongPress(TapControl);

            FlutterDriver.Perform(touchActions);

            FlutterDriver.GetText(FlutterBy.ValueKey("tapCounter")).Should().Be("11", because: "because a tap and long press will increase the counter by 11 (1 + 10)");
        }
Ejemplo n.º 11
0
        public void Tap()
        {
            var touchActions = new FlutterTouchActions().Tap(TapControl);

            FlutterDriver.Perform(touchActions);

            FlutterDriver.GetText(FlutterBy.ValueKey("tapCounter")).Should().Be("1", because: "because a short tap will increase the counter by 1");
        }
Ejemplo n.º 12
0
        public void NavigateToTextTestPage()
        {
            FlutterDriver.Click(FlutterBy.Text("Navigate to Taps Test Page"));

            FlutterDriver.WaitFor(FlutterBy.Text("Taps Page"));

            FlutterDriver.GetText(FlutterBy.ValueKey("tapCounter")).Should().Be("0", because: "the counter is initially 0");
        }
Ejemplo n.º 13
0
        public void GetSemanticsId_ByScript()
        {
            var result = FlutterDriver.ExecuteScript("flutter:getSemanticsId", FlutterBy.Tooltip("FUT: FlutterBy.Tooltip (Increment 3)").ToBase64());

            result.Should().BeOfType(typeof(long));

            ((long)result).Should().NotBe(0);
        }
Ejemplo n.º 14
0
        public void SetupScreenshotTests()
        {
            // NOTE: If we take the screenshot immediately on app startup, we occasionally get this error:
            // Original error: {"code":-32000,"message":"Could not capture image screenshot."}
            //
            // So its better to wait for some state to converge first
            FlutterDriver.WaitFor(FlutterBy.Text("Navigate to Finders and Position Test Page"));

            OutputPath = System.IO.Path.Combine(TestContext.TestRunResultsDirectory, $"{DateTime.Now.ToString("yyyyMMddHHmmss")}.png");
        }
Ejemplo n.º 15
0
        public void Screenshot_Raw()
        {
            var result = FlutterDriver.Screenshot();

            result.Length.Should().BeGreaterThan(0, because: "we are expecting a screenshot to be returned. ");

            System.IO.File.WriteAllBytes(OutputPath, result);

            System.Drawing.Image.FromFile(OutputPath);
        }
Ejemplo n.º 16
0
        public void WaitForAbsent_ExistsForFailQuickly_ByDriver()
        {
            try
            {
                FlutterDriver.WaitForAbsent(ControlThatAlwaysExists, timeoutInSeconds: 1);

                Assert.Fail($"We should never see this statement - the control being searched for ALWAYS EXISTS; so an exception should have been thrown. ");
            }
            catch (OpenQA.Selenium.WebDriverException ex)
            {
                ex.Message.Should().Contain("Timeout while executing waitForAbsent");
            }
        }
Ejemplo n.º 17
0
        public void WaitFor_NeverExists_Driver()
        {
            // TODO: Better exception
            try
            {
                FlutterDriver.WaitFor(ControlThatNeverExists, 1);

                Assert.Fail($"We should never see this statement - the control being searched for ALWAYS EXISTS; so an exception should have been thrown. ");
            }
            catch (OpenQA.Selenium.WebDriverException ex)
            {
                ex.Message.Should().Contain("Timeout while executing waitFor");
            }
        }
Ejemplo n.º 18
0
        public void WaitForAbsent_ExistsForFailQuickly_ByScript()
        {
            try
            {
                // NOTE: The final parameter is in SECONDS
                FlutterDriver.ExecuteScript("flutter:waitForAbsent", ControlThatAlwaysExists.ToBase64(), 1);

                Assert.Fail($"We should never see this statement - the control being searched for ALWAYS EXISTS; so an exception should have been thrown. ");
            }
            catch (OpenQA.Selenium.WebDriverException ex)
            {
                ex.Message.Should().Contain("Timeout while executing waitForAbsent");
            }
        }
Ejemplo n.º 19
0
        public void GetRenderObjectDiagnostics_Javascript()
        {
            var by = FlutterBy.ValueKey("counter");

            var response = FlutterDriver.ExecuteScript("flutter:getRenderObjectDiagnostics", by.ToBase64(), new Dictionary <string, object>()
            {
                { "includeProperties", true },
                { "subtreeDepth", 2 }
            });

            var responseAsDictionary = response as Dictionary <string, object>;

            AssertGetRenderObjectDiagnosticsResponse(responseAsDictionary);
        }
Ejemplo n.º 20
0
        public void WaitForAbsent_NeverExists_ByScript()
        {
            // HACK: On my own box, there is no issue - but when I run this on the CI/CD I get the following error:

            /*
             *  Test method GreyhamWooHoo.Flutter.SystemTests.WaitForTests.WaitForAbsent_NeverExists_ByScript threw exception:
             *  OpenQA.Selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot execute command waitForAbsent, server reponse {
             *  "isError": true,
             *  "response": "Timeout while executing waitForAbsent: TimeoutException after 0:00:01.000000: Future not completed\n",
             *  "type": "_extensionType",
             *  "method": "ext.flutter.driver"
             *  } */

            // To get around this, I wait for the page to 'converge' first
            FlutterDriver.WaitFor(ControlThatAlwaysExists);

            // NOTE: The final parameter is in SECONDS
            FlutterDriver.ExecuteScript("flutter:waitForAbsent", ControlThatNeverExists.ToBase64(), 1);
        }
Ejemplo n.º 21
0
        protected static IFlutterDriver StartApplication()
        {
            if (!System.IO.File.Exists(AndroidAppPath))
            {
                throw new System.IO.FileNotFoundException($"To run the system tests, you need the sample app at '{AndroidAppPath}'. See the README.md file for more information. ");
            }

            var capabilities = new AppiumOptions();

            // Emulator and App Path
            capabilities.AddAdditionalCapability(MobileCapabilityType.Udid, "emulator-5554");
            capabilities.AddAdditionalCapability(MobileCapabilityType.App, AndroidAppPath);

            // Other stuff
            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Pixel 2");
            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "10");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.NativeWebScreenshot, false);
            capabilities.AddAdditionalCapability("buildToolsVersion", "28.0.3");
            capabilities.AddAdditionalCapability("uiautomator2ServerInstallTimeout", 60000);
            capabilities.AddAdditionalCapability("uiautomator2ServerLaunchTimeout", 60000);
            capabilities.AddAdditionalCapability("adbExecTimeout", 60000);
            capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, "Flutter");
            capabilities.AddAdditionalCapability(MobileCapabilityType.NoReset, false);
            capabilities.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, ReadEnvironmentVariable("TESTAPP_MOBILECAPABILITYTYPE_NEWCOMMANDTIMEOUT", orFallbackTo: 60000));

            // TODO:
            var addressOfRemoteServer = new Uri("http://127.0.0.1:4723/wd/hub");
            var commandExecutor       = new HttpCommandExecutor(addressOfRemoteServer, TimeSpan.FromSeconds(ReadEnvironmentVariable("TESTAPP_HTTPEXECUTOR_TIMEOUT_IN_SECONDS", orFallbackTo: 60)));
            var webDriver             = new AndroidDriver <IWebElement>(commandExecutor, capabilities);

            // NOTE: ElementTimeoutInSeconds is the default only for WaitFor and WaitForAbsent at the moment
            var fd = new FlutterDriver(webDriver, commandExecutor, elementTimeoutInSeconds: 30);

            return(fd);
        }
Ejemplo n.º 22
0
        public void EnterText()
        {
            FlutterDriver.SendKeys(TextFieldControl, "something");

            // NOTE: Not sure of the API to retrieve the text value of the given control...
        }
Ejemplo n.º 23
0
 public void NavigateToFindersPage()
 {
     FlutterDriver.Click(FlutterBy.Text("Navigate to Finders and Position Test Page"));
 }
Ejemplo n.º 24
0
        public void NavigateToPageback()
        {
            FlutterDriver.Click(FlutterBy.Text("Navigate to Finders and Position Test Page"));

            FlutterDriver.WaitForAbsent(FlutterBy.Text("Navigate to Finders and Position Test Page"));
        }
Ejemplo n.º 25
0
        public void PageBack()
        {
            FlutterDriver.Click(FlutterBy.PageBack());

            FlutterDriver.WaitFor(FlutterBy.Text("Navigate to Finders and Position Test Page"));
        }
Ejemplo n.º 26
0
        public void NavigateToTextTestPage()
        {
            FlutterDriver.Click(FlutterBy.Text("Navigate to Text Fields Test Page"));

            FlutterDriver.WaitFor(TextFieldControl);
        }
Ejemplo n.º 27
0
        public void GetRenderObjectDiagnostics_Driver()
        {
            var response = FlutterDriver.GetRenderObjectDiagnostics(FlutterBy.ValueKey("counter"), includeProperties: true, subtreeDepth: 2);

            AssertGetRenderObjectDiagnosticsResponse(response);
        }
Ejemplo n.º 28
0
        public void GetSemanticsId_Driver()
        {
            var semanticsId = FlutterDriver.GetSemanticsId(FlutterBy.Type("FlatButton"));

            semanticsId.Should().NotBe(0);
        }
Ejemplo n.º 29
0
        private void AssertCounterIs(string value, string because)
        {
            var result = FlutterDriver.GetText(FlutterBy.ValueKey("counter"));

            result.Should().Be(value, because);
        }
Ejemplo n.º 30
0
 public void ClearText()
 {
     FlutterDriver.SendKeys(TextFieldControl, "something");
     FlutterDriver.Clear(TextFieldControl);
 }