public void Bugzilla26171Test() { RunningApp.WaitForElement(q => q.Marked("lblValue")); var value = RunningApp.Query(q => q.Marked("lblValue")) [0].Text; RunningApp.Screenshot("I see the Label"); }
public void ScrollListViewInsideScrollView() { #if __ANDROID__ if (!RunningApp.IsApiHigherThan(21)) { return; } #endif RunningApp.WaitForElement("1"); RunningApp.QueryUntilPresent(() => { try { RunningApp.ScrollDownTo("30", strategy: ScrollStrategy.Gesture, swipeSpeed: 100); } catch { // just ignore if it fails so it can keep trying to scroll } return(RunningApp.Query("30")); }); RunningApp.Query("30"); }
public void Bugzilla36559Test() { RunningApp.WaitForElement(q => q.Marked("entry")); var results = RunningApp.Query(q => q.Marked("entry")); Assert.AreNotEqual(results[0].Rect.Height, -1); }
void WaitForTextQuery(string text) { var watch = new Stopwatch(); watch.Start(); // 4-5 seconds should be more than enough time to wait for the query to work while (watch.ElapsedMilliseconds < 5000) { // We have to query this way (instead of just using WaitForElement) because // WaitForElement on iOS won't find text in Entry or Editor // And we can't rely on running this query immediately after entering the text into the control // because on Android the query will occasionally fail if it runs too soon after entering the text var textQuery = RunningApp.Query(query => query.Text(text)); if (textQuery.Length > 0) { return; } Task.Delay(1000).Wait(); } watch.Stop(); Assert.Fail($"Timed out waiting for text '{text}'"); }
void TapOnPicker(int index) { var picker = RunningApp.Query(q => q.TextField().Class("PickerEditText"))[index]; var location = picker.Rect; RunningApp.TapCoordinates(location.X + 10, location.Y + location.Height / 2); }
public void Bugzilla30353Test() { var dontRun = RunningApp.Query(q => q.Marked("Don't run")); if (dontRun.Length > 0) { return; } RunningApp.SetOrientationPortrait(); RunningApp.Screenshot("Portrait"); RunningApp.Tap(q => q.Marked("Toggle")); RunningApp.Screenshot("Portrait Visible"); RunningApp.WaitForElement(q => q.Marked("The Master is now visible")); Back(); RunningApp.Screenshot("Portrait Invisible"); RunningApp.WaitForElement(q => q.Marked("The Master is now invisible")); RunningApp.SetOrientationLandscape(); RunningApp.Screenshot("Landscape Invisible"); RunningApp.WaitForElement(q => q.Marked("The Master is now invisible")); RunningApp.Tap(q => q.Marked("Toggle")); RunningApp.Screenshot("Landscape Visible"); RunningApp.WaitForElement(q => q.Marked("The Master is now visible")); Back(); RunningApp.Screenshot("Landscape InVisible"); RunningApp.WaitForElement(q => q.Marked("The Master is now invisible")); RunningApp.SetOrientationPortrait(); RunningApp.Tap(q => q.Marked("Toggle")); RunningApp.Screenshot("Portrait Visible"); RunningApp.WaitForElement(q => q.Marked("The Master is now visible")); Back(); RunningApp.Screenshot("Portrait Invisible"); RunningApp.WaitForElement(q => q.Marked("The Master is now invisible")); RunningApp.SetOrientationLandscape(); }
public void Issue4187Test() { RunningApp.WaitForElement("Text 1"); UITest.Queries.AppResult[] fields = RunningApp.Query(q => q.TextField()); Assert.AreEqual(7, GetPickerEditText(RunningApp).Length, "picker count"); TapOnPicker(1); Assert.IsTrue(DialogIsOpened(), "#1"); RunningApp.Tap("Text 2"); Assert.IsFalse(DialogIsOpened(), "#2"); TapOnPicker(3); Assert.IsTrue(DialogIsOpened(), "#3"); RunningApp.Tap("Text 1"); Assert.IsFalse(DialogIsOpened(), "#5"); // Carousel - first page RunningApp.Back(); RunningApp.ScrollUp(); TapOnPicker(0); Assert.IsTrue(DialogIsOpened(), "Carousel - #1"); // Red page RunningApp.SwipeRightToLeft(); Assert.IsFalse(DialogIsOpened(), "Carousel - #2"); TapOnPicker(0); Assert.IsTrue(DialogIsOpened(), "Carousel - #3"); // Blue page RunningApp.SwipeRightToLeft(); Assert.IsFalse(DialogIsOpened(), "Carousel - #4"); TapOnPicker(0); Assert.IsTrue(DialogIsOpened(), "Carousel - #5"); }
public void TestFocusIsOnTheEndAfterSettingText() { RunningApp.Tap(c => c.Marked("userNameEditorEmptyString")); RunningApp.EnterText("1"); PressEnter(); Assert.Greater(RunningApp.Query(c => c.Marked("focused1")).Length, 0); }
public void Issue3475TestsLayoutCompressionPerformance() { RunningApp.WaitForElement(_titleLabelId); RunningApp.WaitForElement(_withoutCompressionBtnId); RunningApp.WaitForElement(_withCompressionBtnId); RunningApp.Tap(_withoutCompressionBtnId); RunningApp.WaitForElement(DoneLabelId); RunningApp.Screenshot("Without Layout Compression"); int elapsedWithoutCompression = GetMs(RunningApp.Query(ElapsedLabelId).First().Text); RunningApp.Tap(BackButtonId); RunningApp.WaitForElement(_withCompressionBtnId); RunningApp.Tap(_withCompressionBtnId); RunningApp.WaitForElement(DoneLabelId); RunningApp.Screenshot("With Layout Compression"); int elapsedWithCompression = GetMs(RunningApp.Query(ElapsedLabelId).First().Text); var delta = elapsedWithCompression - elapsedWithoutCompression; //if layoutcompressions is slower than 100 then there is a problem. //it should be at least very similar and no more than 100ms slower i guess... Assert.LessOrEqual(delta, 100); }
public void Bugzilla26993Test() { RunningApp.Screenshot("I am at BZ26993"); #if __IOS__ RunningApp.WaitForElement(q => q.Class("WKWebView"), postTimeout: TimeSpan.FromSeconds(5)); RunningApp.Query(q => q.Class("WKWebView").Index(0).InvokeJS("document.getElementById('LinkID0').click()")); RunningApp.Screenshot("Load local HTML"); RunningApp.WaitForNoElement(q => q.Class("WKWebView").Css("#LinkID0")); UITest.Queries.AppWebResult[] newElem = RunningApp.QueryUntilPresent(() => RunningApp.Query(q => q.Class("WKWebView").Css("a"))); Assert.AreEqual("#LocalHtmlPageLink", newElem[0].Id); #elif __ANDROID__ RunningApp.WaitForElement(q => q.WebView(0).Css("#CellID0")); RunningApp.Tap(q => q.WebView(0).Css("#LinkID0")); RunningApp.Screenshot("Load local HTML"); RunningApp.WaitForNoElement(q => q.WebView(0).Css("#LinkID0")); UITest.Queries.AppWebResult[] newElem = RunningApp.QueryUntilPresent(() => RunningApp.Query(q => q.WebView(0).Css("h1"))); Assert.AreEqual("#LocalHtmlPage", newElem[0].Id); #endif RunningApp.Screenshot("I see the Label"); }
public void Issue2577Test() { RunningApp.WaitForElement(NavButton); RunningApp.Tap(NavButton); RunningApp.WaitForElement(ToggleBackButton); RunningApp.Screenshot("Hamburger menu icon is visible"); AppResult[] items = RunningApp.Query(ArrowButton); Assert.AreNotEqual(items.Length, 0); RunningApp.Tap(ArrowButton); RunningApp.WaitForElement(MasterList); RunningApp.Screenshot("Flyout menu is showing"); RunningApp.SwipeRightToLeft(); RunningApp.WaitForNoElement(MasterList); RunningApp.Tap(ToggleBackButton); items = RunningApp.Query(ArrowButton); Assert.AreEqual(items.Length, 0); RunningApp.Screenshot("Back arrow is showing"); var backArrow = RunningApp.Query(e => e.Class("Toolbar").Descendant("AppCompatImageButton")).Last(); RunningApp.TapCoordinates(backArrow.Rect.CenterX, backArrow.Rect.CenterY); RunningApp.WaitForElement(NavButton); RunningApp.Screenshot("Back at first screen"); }
public void Bugzilla35736Test() { RunningApp.WaitForElement(q => q.Marked("Bugzilla35736Editor")); RunningApp.EnterText(q => q.Marked("Bugzilla35736Editor"), "Testig"); RunningApp.Tap(q => q.Marked("Bugzilla35736Button")); Assert.AreEqual("Testing", RunningApp.Query(q => q.Marked("Bugzilla35736Label"))[0].Text); }
public void Issue12574Test() { RunningApp.WaitForElement("0 item"); var rect = RunningApp.Query(c => c.Marked(carouselAutomationId)).First().Rect; var centerX = rect.CenterX; var rightX = rect.X - 5; RunningApp.DragCoordinates(centerX + 40, rect.CenterY, rightX, rect.CenterY); RunningApp.WaitForElement("1 item"); RunningApp.DragCoordinates(centerX + 40, rect.CenterY, rightX, rect.CenterY); RunningApp.WaitForElement("2 item"); RunningApp.Tap(btnRemoveAutomationId); RunningApp.WaitForElement("1 item"); rightX = rect.X + rect.Width - 1; RunningApp.DragCoordinates(rect.X, rect.CenterY, rightX, rect.CenterY); RunningApp.WaitForElement("0 item"); }
public void Issue2963Test() { RunningApp.Screenshot("I am at Issue 2963"); RunningApp.Tap(q => q.Marked(_editorId)); Assert.AreEqual("False", RunningApp.Query(q => q.Marked(_focusedLabelId))[0].Text); RunningApp.Screenshot("Label should still be false"); }
public void FlyoutPageIsPresentedChangedRaised() { var dontRun = RunningApp.Query(q => q.Marked("Don't run")); if (dontRun.Length > 0) { return; } RunningApp.SetOrientationPortrait(); RunningApp.Screenshot("Portrait"); RunningApp.Tap(q => q.Marked("Toggle")); RunningApp.Screenshot("Portrait Visible"); RunningApp.WaitForElement(q => q.Marked("The Flyout is now visible")); Back(); RunningApp.Screenshot("Portrait Invisible"); RunningApp.WaitForElement(q => q.Marked("The Flyout is now invisible")); RunningApp.SetOrientationLandscape(); RunningApp.Screenshot("Landscape Invisible"); RunningApp.WaitForElement(q => q.Marked("The Flyout is now invisible")); RunningApp.Tap(q => q.Marked("Toggle")); RunningApp.Screenshot("Landscape Visible"); RunningApp.WaitForElement(q => q.Marked("The Flyout is now visible")); Back(); RunningApp.Screenshot("Landscape InVisible"); RunningApp.WaitForElement(q => q.Marked("The Flyout is now invisible")); RunningApp.SetOrientationPortrait(); RunningApp.Tap(q => q.Marked("Toggle")); RunningApp.Screenshot("Portrait Visible"); RunningApp.WaitForElement(q => q.Marked("The Flyout is now visible")); Back(); RunningApp.Screenshot("Portrait Invisible"); RunningApp.WaitForElement(q => q.Marked("The Flyout is now invisible")); RunningApp.SetOrientationLandscape(); }
public void Bugzilla31330Test() { RunningApp.WaitForElement(c => c.Marked("Something 2")); var screenBounds = RunningApp.Query(q => q.Raw("* index:0"))[0].Rect; var cell = RunningApp.Query(c => c.Marked("Something 1")) [0]; var cell2 = RunningApp.Query(c => c.Marked("Something 2")) [0]; #if __IOS__ RunningApp.DragCoordinates(screenBounds.Width - 10, cell.Rect.CenterY, 0, cell.Rect.CenterY); RunningApp.WaitForElement(c => c.Marked("Delete")); RunningApp.Tap(c => c.Marked("Delete")); RunningApp.WaitForElement(c => c.Marked("Something 1")); RunningApp.Tap(c => c.Marked("Something 2")); RunningApp.DragCoordinates(screenBounds.Width - 10, cell2.Rect.CenterY, 0, cell2.Rect.CenterY); RunningApp.Tap(c => c.Marked("Delete")); RunningApp.WaitForNoElement(c => c.Marked("Something 2")); #else RunningApp.TouchAndHoldCoordinates(cell.Rect.CenterX, cell.Rect.CenterY); RunningApp.WaitForElement(c => c.Marked("Delete")); RunningApp.Tap(c => c.Marked("Delete")); RunningApp.Back(); RunningApp.WaitForElement(c => c.Marked("Something 1")); RunningApp.Tap(c => c.Marked("Something 2")); RunningApp.TouchAndHoldCoordinates(cell2.Rect.CenterX, cell2.Rect.CenterY); RunningApp.Tap(c => c.Marked("Delete")); RunningApp.WaitForNoElement(c => c.Marked("Something 2")); #endif }
public void Bugzilla32230Test() { RunningApp.Tap(q => q.Marked("btnOpen")); Assert.AreEqual("1", RunningApp.Query(q => q.Marked("lblCount"))[0].Text); RunningApp.Tap(q => q.Marked("btnClose")); RunningApp.Tap(q => q.Marked("btnOpen")); Assert.AreEqual("3", RunningApp.Query(q => q.Marked("lblCount"))[0].Text); }
public void Issue31333FocusEditorInTableViewCell() { RunningApp.Tap(q => q.Marked("Focus Editor in Table")); RunningApp.Screenshot("Editor control in TableView cell is focused"); RunningApp.EnterText("Editor in TableView Success"); Assert.True(RunningApp.Query(query => query.Text("Editor in TableView Success")).Length > 0); RunningApp.Screenshot("Editor in TableView Success"); }
public void Bugzilla36955Test() { AppResult[] buttonFalse = RunningApp.Query(q => q.Button().Text("False")); Assert.AreEqual(buttonFalse.Length == 1, true); RunningApp.Tap(q => q.Class("Switch")); AppResult[] buttonTrue = RunningApp.Query(q => q.Button().Text("True")); Assert.AreEqual(buttonTrue.Length == 1, true); }
public void Issue35127Test() { RunningApp.WaitForElement(q => q.Marked("See me?")); var count = RunningApp.Query(q => q.Marked("scrollView")).Length; Assert.IsTrue(count == 0); RunningApp.WaitForNoElement(q => q.Marked("Click Me?")); }
void ScrollNextItem() { var rect = RunningApp.Query(c => c.Marked("carouselView")).First().Rect; var centerX = rect.CenterX; var rightX = rect.X - 5; RunningApp.DragCoordinates(centerX + 40, rect.CenterY, rightX, rect.CenterY); }
public void Bugzilla39530PanTest() { AppRect frameBounds = RunningApp.Query(q => q.Marked("frame"))[0].Rect; RunningApp.Pan(new Drag(frameBounds, frameBounds.X + 10, frameBounds.Y + 10, frameBounds.X + 100, frameBounds.Y + 100, Drag.Direction.LeftToRight)); RunningApp.WaitForElement(q => q.Marked("Panning: Completed")); }
public void VariousSpanGesturePermutation() { RunningApp.WaitForElement($"{kGesture1}0"); RunningApp.WaitForElement($"{kGesture2}0"); var labelId = RunningApp.WaitForElement(kLabelAutomationId); var target = labelId.First().Rect; for (int i = 1; i < 5; i++) { RunningApp.Tap($"TestSpan{i}"); // These tap retries work around a Tap Coordinate bug // with Xamarin.UITest >= 3.0.7 int tapAttempts = 0; do { RunningApp.TapCoordinates(target.X + 5, target.Y + 5); if (tapAttempts == 4) { RunningApp.WaitForElement($"{kGesture1}{i}"); } tapAttempts++; } while (RunningApp.Query($"{kGesture1}{i}").Length == 0); tapAttempts = 0; do { #if __WINDOWS__ RunningApp.TapCoordinates(target.X + target.Width - 10, target.Y + 2); #else RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2); #endif if (tapAttempts == 4) { RunningApp.WaitForElement($"{kGesture1}{i}"); } tapAttempts++; } while (RunningApp.Query($"{kGesture2}{i}").Length == 0); } RunningApp.Tap($"TestSpan5"); RunningApp.TapCoordinates(target.X + 5, target.Y + 5); #if __WINDOWS__ RunningApp.TapCoordinates(target.X + target.Width - 10, target.Y + 2); #else RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2); #endif RunningApp.WaitForElement($"{kGesture1}4"); RunningApp.WaitForElement($"{kGesture2}4"); }
public void TestIsEnabledTrue() { var disable1 = RunningApp.Query(c => c.Marked("txtCellEnable1")) [0]; Assert.IsTrue(disable1.Enabled); var disable2 = RunningApp.Query(c => c.Marked("txtCellEnable2")) [0]; Assert.IsTrue(disable2.Enabled); }
public void MoreControllerDoesNotShowEditButton() { RunningApp.WaitForElement(x => x.Class("UITabBarButton").Marked("More")); RunningApp.Tap(x => x.Class("UITabBarButton").Marked("More")); RunningApp.WaitForElement(x => x.Class("UITableViewCell").Text("Tab 5")); Assert.AreEqual(RunningApp.Query(x => x.Marked("Edit")).Count(), 0); }
public void Bugzilla44886Test() { RunningApp.WaitForElement(q => q.Marked(Item1)); RunningApp.Tap(q => q.Marked(Item1)); int count = int.Parse(RunningApp.Query(q => q.Marked(CountId))[0].Text); Assert.IsTrue(count == 1); }
void TestForImageNotVisible(UITest.Queries.AppResult previousFinding) { var imageVisible = RunningApp.Query(_fileNameAutomationId); if (imageVisible.Length > 0) { Assert.Less(imageVisible[0].Rect.Height, previousFinding.Rect.Height); } }
public void TestFocusIsOnTheEndAfterSettingText() { RunningApp.WaitForElement("userNameEditorEmptyString"); RunningApp.Tap(c => c.Marked("userNameEditorEmptyString")); RunningApp.EnterText("1"); PressEnter(); var q = RunningApp.Query(c => c.Marked("userNameEditorEmptyString")); Assert.AreEqual("focused1", q[0].Text); }
public void TestIsEnabledFalse() { if (RunningApp is iOSApp) { var disable1 = RunningApp.Query(c => c.Marked("txtCellDisable1")) [0]; Assert.IsFalse(disable1.Enabled); var disable2 = RunningApp.Query(c => c.Marked("txtCellDisable2")) [0]; Assert.IsFalse(disable2.Enabled); } }
public void Issue12848Test() { RunningApp.WaitForElement("TestCarouselView"); RunningApp.SwipeRightToLeft(); Assert.AreEqual(1, int.Parse(RunningApp.Query(q => q.Marked("CarouselPosition"))[0].Text)); RunningApp.Tap("HideButton"); RunningApp.Tap("ShowButton"); Assert.AreEqual(1, int.Parse(RunningApp.Query(q => q.Marked("CarouselPosition"))[0].Text)); RunningApp.Screenshot("Test passed"); }