Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TECH: fix system dialog provider #460

Merged
merged 2 commits into from Dec 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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.
Expand Down Expand Up @@ -100,10 +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,
* 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("android").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
}
Expand Down