From 1d6299de93d3b09d565f0caf1ae47cf38043f1b9 Mon Sep 17 00:00:00 2001 From: Dor Blayzer <59066376+Dor-bl@users.noreply.github.com> Date: Fri, 4 Oct 2024 08:51:25 +0300 Subject: [PATCH] fix(test): add explicit wait for app package to load before assertion (#838) --- test/integration/Android/CurrentPackageTest.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/integration/Android/CurrentPackageTest.cs b/test/integration/Android/CurrentPackageTest.cs index 07a44caf..1559ea61 100644 --- a/test/integration/Android/CurrentPackageTest.cs +++ b/test/integration/Android/CurrentPackageTest.cs @@ -1,6 +1,8 @@ using Appium.Net.Integration.Tests.helpers; using NUnit.Framework; using OpenQA.Selenium.Appium.Android; +using OpenQA.Selenium.Support.UI; +using System; namespace Appium.Net.Integration.Tests.Android { @@ -8,6 +10,9 @@ namespace Appium.Net.Integration.Tests.Android public class CurrentPackageTest { private AndroidDriver _driver; + private WebDriverWait _waitDriver; + private readonly TimeSpan _driverTimeOut = TimeSpan.FromSeconds(5); + private const string DemoAppPackage = "io.appium.android.apis"; [OneTimeSetUp] @@ -37,6 +42,8 @@ public void TearDowwn() [Test] public void ReturnsCorrectNameForCurrentApp() { + _waitDriver = new WebDriverWait(_driver, _driverTimeOut); + _waitDriver.Until(driver => _driver.CurrentPackage == DemoAppPackage); Assert.That(_driver.CurrentPackage, Is.EqualTo(DemoAppPackage)); } }