From e59d19d4f42970a25dce7151b3a0410e02749a31 Mon Sep 17 00:00:00 2001 From: Mille Date: Wed, 19 Jul 2017 21:46:55 +0200 Subject: [PATCH] Added so you can check if visible or hidden in cache --- .../Device/Ui/Objects/BaseUiObject.cs | 26 +++++++++++++++++++ .../Device/Ui/Objects/UiObject.cs | 5 ++++ .../Device/Ui/Objects/UiObjects.cs | 5 ++++ 3 files changed, 36 insertions(+) diff --git a/src/Testura.Android/Device/Ui/Objects/BaseUiObject.cs b/src/Testura.Android/Device/Ui/Objects/BaseUiObject.cs index b4a0fd8..92122df 100644 --- a/src/Testura.Android/Device/Ui/Objects/BaseUiObject.cs +++ b/src/Testura.Android/Device/Ui/Objects/BaseUiObject.cs @@ -60,6 +60,15 @@ public bool IsVisible(int timeout = 10) } } + /// + /// Check if node(s) is visible in cache. + /// + /// True if visible in cache, otherwise false. + public bool IsVisibleInCache() + { + return IsVisible(-1); + } + /// /// Wait for the node(s) to be hidden. /// @@ -85,6 +94,23 @@ public bool IsHidden(int timeout = 10) } } + /// + /// Check if node(s) is hidden in cache. + /// + /// True if hidden, otherwise false. + public bool IsHiddenInCache() + { + try + { + TryFindNode(-1); + return false; + } + catch (UiNodeNotFoundException) + { + return true; + } + } + /// /// Find node(s) on the screen. /// diff --git a/src/Testura.Android/Device/Ui/Objects/UiObject.cs b/src/Testura.Android/Device/Ui/Objects/UiObject.cs index 0247256..f3f580a 100644 --- a/src/Testura.Android/Device/Ui/Objects/UiObject.cs +++ b/src/Testura.Android/Device/Ui/Objects/UiObject.cs @@ -94,6 +94,11 @@ public bool WaitForValue(Func expectedValues, int timeout = 20) /// All found node(s) protected override IList TryFindNode(int timeout) { + if (timeout == -1) + { + return new List { Device.Ui.FindNodeFromCache(Withs) }; + } + return new List { Device.Ui.FindNode(timeout, Withs) }; } } diff --git a/src/Testura.Android/Device/Ui/Objects/UiObjects.cs b/src/Testura.Android/Device/Ui/Objects/UiObjects.cs index aa7bc49..f9f67fa 100644 --- a/src/Testura.Android/Device/Ui/Objects/UiObjects.cs +++ b/src/Testura.Android/Device/Ui/Objects/UiObjects.cs @@ -37,6 +37,11 @@ public IList ValuesFromCache() protected override IList TryFindNode(int timeout) { + if (timeout == -1) + { + return Device.Ui.FindNodesFromCache(Withs); + } + return Device.Ui.FindNodes(timeout, Withs); } }