public void GetBottomRight_Driver() { var response = FlutterDriver.GetBottomRight(Control); response.Dx.Should().BeGreaterThan(0); response.Dy.Should().BeGreaterThan(0); }
public void ByText() { // Text FlutterDriver.Click(FlutterBy.Text("FUT: FlutterBy.Text (Increment 1)")); AssertCounterIs("1", because: "we pressed the Add+1 button"); }
public void GetCenter_Driver() { var response = FlutterDriver.GetCenter(Control); response.Dx.Should().BeGreaterThan(0); response.Dy.Should().BeGreaterThan(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"); }
public void ByValueKey() { // Text FlutterDriver.Click(FlutterBy.ValueKey("FUT: FlutterBy.ValueKey (Increment 2)")); AssertCounterIs("2", because: "we pressed the Add+2 button"); }
public void GetTopleft_Driver() { var response = FlutterDriver.GetTopLeft(Control); response.Dx.Should().BeGreaterThan(0); response.Dy.Should().BeGreaterThan(0); }
public void ByTooltip() { // Text FlutterDriver.Click(FlutterBy.Tooltip("FUT: FlutterBy.Tooltip (Increment 3)")); AssertCounterIs("3", because: "we pressed the Add+3 button"); }
public void ByType() { // Text FlutterDriver.Click(FlutterBy.Type("FlatButton")); AssertCounterIs("-4", because: "we pressed the Add button (Flat Button)"); }
public void BySemanticsLabel() { // Text FlutterDriver.Click(FlutterBy.SemanticsLabel("FUT: FlutterBy.SemanticsLabel (Increment 4)")); AssertCounterIs("4", because: "we pressed the Semantics Label button"); }
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)"); }
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"); }
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"); }
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); }
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"); }
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); }
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"); } }
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"); } }
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"); } }
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); }
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); }
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); }
public void EnterText() { FlutterDriver.SendKeys(TextFieldControl, "something"); // NOTE: Not sure of the API to retrieve the text value of the given control... }
public void NavigateToFindersPage() { FlutterDriver.Click(FlutterBy.Text("Navigate to Finders and Position Test Page")); }
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")); }
public void PageBack() { FlutterDriver.Click(FlutterBy.PageBack()); FlutterDriver.WaitFor(FlutterBy.Text("Navigate to Finders and Position Test Page")); }
public void NavigateToTextTestPage() { FlutterDriver.Click(FlutterBy.Text("Navigate to Text Fields Test Page")); FlutterDriver.WaitFor(TextFieldControl); }
public void GetRenderObjectDiagnostics_Driver() { var response = FlutterDriver.GetRenderObjectDiagnostics(FlutterBy.ValueKey("counter"), includeProperties: true, subtreeDepth: 2); AssertGetRenderObjectDiagnosticsResponse(response); }
public void GetSemanticsId_Driver() { var semanticsId = FlutterDriver.GetSemanticsId(FlutterBy.Type("FlatButton")); semanticsId.Should().NotBe(0); }
private void AssertCounterIs(string value, string because) { var result = FlutterDriver.GetText(FlutterBy.ValueKey("counter")); result.Should().Be(value, because); }
public void ClearText() { FlutterDriver.SendKeys(TextFieldControl, "something"); FlutterDriver.Clear(TextFieldControl); }