From a3efaa8da9adb102d0ac31a1f96b42c0abd75030 Mon Sep 17 00:00:00 2001 From: Areyana Date: Wed, 21 Dec 2022 14:46:36 +0300 Subject: [PATCH 1/2] TECH: fix system dialog provider --- .../kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt index 933947981..c86ccef4f 100644 --- a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt +++ b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt @@ -9,6 +9,7 @@ import com.kaspersky.kaspresso.device.server.AdbServer import com.kaspersky.kaspresso.instrumental.InstrumentalDependencyProvider import com.kaspersky.kaspresso.logger.UiTestLogger import java.util.concurrent.TimeUnit +import java.util.regex.Pattern /** * The implementation of the [SystemDialogSafetyProvider] interface. @@ -100,10 +101,11 @@ class SystemDialogSafetyProviderImpl( /** * Checks if error is allowed and android system dialogs/windows are overlaying the app. + * Aware to use By.pkg with String, cause it will cause to use Pattern.quote in internal code */ private fun isAndroidSystemDetected(): Boolean { with(uiDevice) { - if (isVisible(By.pkg("android").clazz(FrameLayout::class.java))) { + if (isVisible(By.pkg(Pattern.compile("\\S*android\\S*")).clazz(FrameLayout::class.java))) { logger.i("The android system dialog/window was detected") return true } From e38f9ede1e6d67dc34db41a60ce9334f45b893bf Mon Sep 17 00:00:00 2001 From: Areyana Date: Wed, 21 Dec 2022 16:47:28 +0300 Subject: [PATCH 2/2] TECH: extend regex for system dialog --- .../kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt index c86ccef4f..df44d1356 100644 --- a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt +++ b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt @@ -101,11 +101,12 @@ class SystemDialogSafetyProviderImpl( /** * Checks if error is allowed and android system dialogs/windows are overlaying the app. - * Aware to use By.pkg with String, cause it will cause to use Pattern.quote in internal code + * Aware to use By.pkg with String, cause it will cause to use Pattern.quote in internal code, + * internal use Pattern.match() method, so we need regex that will match full string, not part. */ private fun isAndroidSystemDetected(): Boolean { with(uiDevice) { - if (isVisible(By.pkg(Pattern.compile("\\S*android\\S*")).clazz(FrameLayout::class.java))) { + if (isVisible(By.pkg(Pattern.compile("\\S*google.android\\S*")).clazz(FrameLayout::class.java))) { logger.i("The android system dialog/window was detected") return true }