KasperskyLab / Kaspresso

Android UI test framework

Home Page:https://kasperskylab.github.io/Kaspresso/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to disable isAndroidSystemDetected when I use allure?

sergeev-roman opened this issue · comments

15:22:58.305 KASPRESSO The suppressing of SystemDialogs starts
15:22:58.305 KASPRESSO The suppressing of SystemDialogs on the try #0 starts
15:22:58.305 KASPRESSO AdbServer. The command to execute=input keyevent KEYCODE_BACK
15:22:58.507 KASPRESSO AdbServer. The command=input keyevent KEYCODE_BACK was performed with result=CommandResult(status=SUCCESS, description=exitCode=0, message=, serviceInfo=The command was executed on desktop=Desktop-26869)
15:22:58.507 KASPRESSO AdbServer. The command to execute=input keyevent KEYCODE_ENTER
15:23:00.391 KASPRESSO AdbServer. The command=input keyevent KEYCODE_ENTER was performed with result=CommandResult(status=SUCCESS, description=exitCode=0, message=, serviceInfo=The command was executed on desktop=Desktop-26869)
15:23:00.391 KASPRESSO AdbServer. The command to execute=input keyevent KEYCODE_ENTER
15:23:01.965 KASPRESSO AdbServer. The command=input keyevent KEYCODE_ENTER was performed with result=CommandResult(status=SUCCESS, description=exitCode=0, message=, serviceInfo=The command was executed on desktop=Desktop-26869)

Hello guys! I need some advise from you
Sometimes KASPRESSO just unexpected closes my application by starting input BACK (this close my application) and 2 times enter (this randomly opens some apps from main screen)

I have no idea why is it turned on by default, because the main part of every test - predictable and this feature makes each test unpredictable.

The question is - how to disable this feature (

) because it's more than useless - its harmful and dangerous for use of randomly start doing actions out of test scenario.

I've started to use Kaspresso.Builder.withForcedAllureSupport() because I need allure and Allure native runner doesnt work properly with kaspresso in 1.5.3

Android Emulator API32
But on API31 it works well

Hi, @readlui! We're sorry, that you find system dialogs interceptor harmful. If you look into it's code you'll find that it checks whether any android system UI elements are present. If so, it tries to close them. Probably, there's a keyboard in your tests (it has the same package as other system UI elements). If so, configure kaspresso to ignore it by setting SystemDialogsSafetyParams in the kaspresso builder:

class AllureSupportTest : TestCase(
    kaspressoBuilder = Kaspresso.Builder.withForcedAllureSupport {
        systemDialogsSafetyParams = SystemDialogsSafetyParams(shouldIgnoreKeyboard = true)
    }
) {
    //...
{

If the issue still presists, then exclude interceptor entirely:

class AllureSupportTest : TestCase(
    kaspressoBuilder = Kaspresso.Builder.withForcedAllureSupport().apply {
        dataBehaviorInterceptors.removeIf { it is SystemDialogSafetyProvider }
        deviceBehaviorInterceptors.removeIf { it is SystemDialogSafetyProvider }
        objectBehaviorInterceptors.removeIf { it is SystemDialogSafetyProvider }
        webBehaviorInterceptors.removeIf { it is SystemDialogSafetyProvider }
        viewBehaviorInterceptors.removeIf { it is SystemDialogSafetyProvider }
    }
) {
    //...
}