public void CommandTest() { RunningApp.Tap(ToggleCommandId); RunningApp.EnterText(EntryCommandParameter, "parameter"); ShowFlyout(); // API 19 workaround var commandResult = RunningApp.QueryUntilPresent(() => { ShowFlyout(); if (RunningApp.WaitForElement(CommandResultId)[0].ReadText() == "parameter") { return(RunningApp.WaitForElement(CommandResultId)); } return(null); })?.FirstOrDefault()?.ReadText(); Assert.AreEqual("parameter", commandResult); RunningApp.EnterText(EntryCommandParameter, "canexecutetest"); RunningApp.Tap(ToggleCommandCanExecuteId); commandResult = RunningApp.QueryUntilPresent(() => { if (RunningApp.WaitForElement(CommandResultId)[0].ReadText() == "parameter") { return(RunningApp.WaitForElement(CommandResultId)); } return(null); })?.FirstOrDefault()?.ReadText(); Assert.AreEqual("parameter", commandResult); }
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 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")); var 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")); Xamarin.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 CommandWorksWhenItsTheOnlyThingSet() { RunningApp.Tap(PushPageId); RunningApp.Tap(ToggleCommandId); RunningApp.EnterText(EntryCommandParameter, "parameter"); // API 19 workaround var commandResult = RunningApp.QueryUntilPresent(() => { #if __ANDROID__ TapBackArrow(); #else RunningApp.Tap("Page 0"); #endif if (RunningApp.WaitForElement(CommandResultId)[0].ReadText() == "parameter") { return(RunningApp.WaitForElement(CommandResultId)); } return(null); })?.FirstOrDefault()?.ReadText(); Assert.AreEqual(commandResult, "parameter"); }
public void Issue2951Test() { RunningApp.WaitForElement("Ready"); var bt = RunningApp.WaitForElement(c => c.Marked("btnChangeStatus")); var buttons = RunningApp.QueryUntilPresent(() => { var results = RunningApp.Query("btnChangeStatus"); if (results.Length == 3) { return(results); } return(null); }); Assert.That(buttons.Length, Is.EqualTo(3)); RunningApp.Tap(c => c.Marked("btnChangeStatus").Index(1)); buttons = RunningApp.QueryUntilPresent(() => { var results = RunningApp.Query("btnChangeStatus"); if ((results[1].Text ?? results[1].Label) == "B") { return(results); } return(null); }); var text = buttons[1].Text ?? buttons[1].Label; Assert.That(text, Is.EqualTo("B")); RunningApp.Tap(c => c.Marked("btnChangeStatus").Index(1)); buttons = RunningApp.QueryUntilPresent(() => { var results = RunningApp.Query("btnChangeStatus"); if (results.Length == 2) { return(results); } return(null); }); Assert.That(buttons.Length, Is.EqualTo(2)); //TODO: we should check the color of the button //var buttonTextColor = GetProperty<Color> ("btnChangeStatus", Button.BackgroundColorProperty); //Assert.AreEqual (Color.Pink, buttonTextColor); }
public void CollectionViewItemsSourceTypesDisplayAndDontCrash() { RunningApp.QueryUntilPresent(() => { var result = RunningApp.WaitForElement("900"); if (result.Length == 3) { return(result); } return(null); }); }
void TestForPopup() { var result = RunningApp.QueryUntilPresent(() => { return(RunningApp.Query("Paste") .Union(RunningApp.Query("Share")) .Union(RunningApp.Query("Copy")) .Union(RunningApp.Query("Cut")) .Union(RunningApp.Query("Select All")) .ToArray()); }); Assert.IsNotNull(result); Assert.IsTrue(result.Length > 0); }
public void Bugzilla26993Test() { RunningApp.Screenshot("I am at BZ26993"); 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); RunningApp.Screenshot("I see the Label"); }
public void LegacyImageSourceProperties() { RunningApp.WaitForElement("Nothing Crashed"); RunningApp.QueryUntilPresent( () => { var result = RunningApp.WaitForElement("Image1"); if (result[0].Rect.Height > 50) { return(result); } return(null); }, 10, 2000); // ensure url images have loaded System.Threading.Thread.Sleep(2000); }
public void CollectionViewInfiniteScroll() { RunningApp.WaitForElement("CollectionView5623"); var colView = RunningApp.Query("CollectionView5623").Single(); AppResult[] lastCellResults = null; RunningApp.QueryUntilPresent(() => { RunningApp.DragCoordinates(colView.Rect.CenterX, colView.Rect.Y + colView.Rect.Height - 50, colView.Rect.CenterX, colView.Rect.Y + 5); lastCellResults = RunningApp.Query("99"); return(lastCellResults); }, 100, 1); Assert.IsTrue(lastCellResults?.Any() ?? false); }
public void Bugzilla43941Test() { for (var n = 0; n < 10; n++) { RunningApp.WaitForElement(q => q.Marked("Push")); RunningApp.Tap(q => q.Marked("Push")); RunningApp.WaitForElement(q => q.Marked("ListView")); RunningApp.Back(); } // At this point, the counter can be any value, but it's most likely not zero. // Invoking GC once is enough to clean up all garbage data and set counter to zero RunningApp.WaitForElement("GC"); RunningApp.QueryUntilPresent(() => { RunningApp.Tap("GC"); return(RunningApp.Query("Counter: 0")); }); }
void ImageCellTest(bool fileSource) { string className = "ImageView"; SetupTest(nameof(ListView), fileSource); var imageVisible = RunningApp.QueryUntilPresent(GetImage, 10, 2000); Assert.AreEqual(1, imageVisible.Length); SetImageSourceToNull(); imageVisible = GetImage(); UITest.Queries.AppResult[] GetImage() { return(RunningApp .Query(app => app.Marked(_theListView).Descendant()) .Where(x => x.Class != null && x.Class.Contains(className)).ToArray()); } }
UITest.Queries.AppResult TestForImageVisible() { var images = RunningApp.QueryUntilPresent(() => { var result = RunningApp.WaitForElement(_fileNameAutomationId); if (result[0].Rect.Height > 1) { return(result); } return(new UITest.Queries.AppResult[0]); }, 10, 4000); Assert.AreEqual(1, images.Length); var imageVisible = images[0]; Assert.Greater(imageVisible.Rect.Height, 1); Assert.Greater(imageVisible.Rect.Width, 1); return(imageVisible); }
public void MonkiesShouldLoad() { RunningApp.WaitForElement("MonkeyLoadButton"); RunningApp.Tap("MonkeyLoadButton"); RunningApp.WaitForElement("monkeysLoaded"); var monkeyImages = RunningApp.QueryUntilPresent(() => { var images = RunningApp.WaitForElement("MonkeyImages"); if (images[0].Rect.Height < 50 || images[0].Rect.Width < 50) { return(null); } return(images); }); Assert.IsNotNull(monkeyImages); Assert.GreaterOrEqual(monkeyImages[0].Rect.Height, 50); Assert.GreaterOrEqual(monkeyImages[0].Rect.Width, 50); }
public void CollectionViewVerticalOffset() { var colView = RunningApp.WaitForElement("CollectionView7993")[0]; RunningApp.WaitForElement(x => x.Marked("VerticalOffset: 0")); AppResult[] lastCellResults = null; RunningApp.QueryUntilPresent(() => { RunningApp.DragCoordinates(colView.Rect.CenterX, colView.Rect.Y + colView.Rect.Height - 50, colView.Rect.CenterX, colView.Rect.Y + 5); lastCellResults = RunningApp.Query("19"); return(lastCellResults); }, 20, 1); Assert.IsTrue(lastCellResults?.Any() ?? false); RunningApp.Tap(x => x.Marked("NewItemsSource")); RunningApp.WaitForElement(x => x.Marked("VerticalOffset: 0")); }
public void DelayedIsRefreshingAndCommandTest_SwipeDown() { var collectionView = RunningApp.WaitForElement(q => q.Marked("CollectionView7803"))[0]; RunningApp.Pan(new Drag(collectionView.Rect, Drag.Direction.TopToBottom, Drag.DragLength.Medium)); RunningApp.WaitForElement(q => q.Marked("Count: 20")); RunningApp.WaitForNoElement(q => q.Marked("Count: 30")); AppResult[] lastCellResults = null; RunningApp.QueryUntilPresent(() => { RunningApp.DragCoordinates(collectionView.Rect.CenterX, collectionView.Rect.Y + collectionView.Rect.Height - 50, collectionView.Rect.CenterX, collectionView.Rect.Y + 5); lastCellResults = RunningApp.Query("19"); return(lastCellResults); }, 10, 1); Assert.IsTrue(lastCellResults?.Any() ?? false); }
public void MasterViewMovesAndContentIsVisible() { var idiom = RunningApp.WaitForElement("Idiom"); // This behavior is currently broken on a phone device Issue 7270 if (idiom[0].ReadText() != "Tablet") { return; } RunningApp.Tap("OpenMasterView"); RunningApp.Tap("CloseMasterView"); RunningApp.SetOrientationLandscape(); RunningApp.Tap("OpenMasterView"); var positionStart = RunningApp.WaitForElement("CloseMasterView"); RunningApp.Tap("ShowLeftToRight"); var results = RunningApp.QueryUntilPresent(() => { var secondPosition = RunningApp.Query("CloseMasterView"); if (secondPosition.Length == 0) { return(null); } if (secondPosition[0].Rect.X < positionStart[0].Rect.X) { return(secondPosition); } return(null); }); Assert.IsNotNull(results, "Master View Did not change flow direction correctly"); Assert.AreEqual(1, results.Length, "Master View Did not change flow direction correctly"); }
public void CollectionViewItemsLayoutUpdate() { RunningApp.WaitForElement("CollectionView5354"); RunningApp.WaitForElement("Button5354"); var colView = RunningApp.Query("CollectionView5354").Single(); for (var i = 0; i < 3; i++) { RunningApp.WaitForNoElement("NoElement", timeout: TimeSpan.FromSeconds(3)); AppResult[] lastCellResults = null; RunningApp.QueryUntilPresent(() => { RunningApp.DragCoordinates(colView.Rect.CenterX, colView.Rect.Y + colView.Rect.Height - 50, colView.Rect.CenterX, colView.Rect.Y + 5); lastCellResults = RunningApp.Query("Image49"); return(lastCellResults); }, 100, 1); RunningApp.Tap("Button5354"); } }
public void Issue6286_WebView_Test() { RunningApp.QueryUntilPresent(() => RunningApp.WaitForElement("success")); }