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

SoftKeyboard is recognized as a SystemDialog #521

Closed
AlexeyRybakov opened this issue May 30, 2023 · 2 comments · Fixed by #529
Closed

SoftKeyboard is recognized as a SystemDialog #521

AlexeyRybakov opened this issue May 30, 2023 · 2 comments · Fixed by #529
Labels
bug Something isn't working

Comments

@AlexeyRybakov
Copy link

Describe the bug

Kaspresso recognizes SoftKeyboard as a SystemDialog and tries to close it.

To Reproduce
Steps to reproduce the behavior:

  1. Start a screen with opened SoftKeyboard
  2. Check not passing assertion to activate FlakySafely mechanism. For example, assert isDisplayed() for non-existent View.
  3. You can see log: The android system dialog/window was detected. The try #0 of the suppressing of SystemDialogs failed.

Expected behavior
The SoftKeyboard should not trigger suspending of SystemDialogs.

Smartphone (please complete the following information):

  • Device: Emulator Pixel 2
  • Version 31

Additional context
It seems like the problem in this line:

if (isVisible(By.pkg(Pattern.compile("\\S*google.android\\S*")).clazz(FrameLayout::class.java))) {

Where SoftKeyboard package is com.google.android.inputmethod.latin

Code to reproduce:

class SimpleTest : TestCase() {

    @get:Rule
    val activityRule = activityScenarioRule<MainActivity>()

    @Test
    fun test() = run {
        KButton { withTag("non-existent view") }.isDisplayed()
    }
}

Activity:

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <requestFocus/>
        </EditText>
<FrameLayout/> 

Logs:

16:46:33.457  I  ___________________________________________________________________________
16:46:33.462  I  ---------------------------------------------------------------------------
16:46:33.462  I  BEFORE TEST SECTION
16:46:33.462  I  ---------------------------------------------------------------------------
16:46:33.463  I  ---------------------------------------------------------------------------
16:46:33.463  I  TEST SECTION
16:46:33.463  I  ---------------------------------------------------------------------------
16:46:34.059  I  Checking 'com.kaspersky.kaspresso.proxy.ViewAssertionProxy@316e4e4' assertion on view (view.getTag() "non-existent view")
16:46:34.059  I  (view.getTag() "non-existent view")
16:46:34.068  E  Failed to interact with view matching: (view.getTag() "non-existent view") because of NoMatchingViewException
16:46:36.758  I  The android system dialog/window was detected
16:46:36.758  I  The suppressing of SystemDialogs starts
16:46:36.758  I  The suppressing of SystemDialogs on the try #0 starts
16:46:36.772  I  AdbServer. The command to execute=input keyevent KEYCODE_BACK
16:46:42.121  I  AdbServer. The command=input keyevent KEYCODE_BACK was performed with result=CommandResult(status=TIMEOUT, description=The time for the connection establishment is over, serviceInfo=null)
16:46:42.268  I  The try #0 of the suppressing of SystemDialogs failed
16:46:42.569  I  The android system dialog/window was detected
16:46:42.573  I  The suppressing of SystemDialogs on the try #1 starts
16:46:45.649  I  The try #1 of the suppressing of SystemDialogs failed
16:46:45.713  I  The android system dialog/window was detected
16:46:45.713  I  The suppressing of SystemDialogs on the try #2 starts
16:46:47.908  I  The try #2 of the suppressing of SystemDialogs failed
16:46:47.998  I  The android system dialog/window was detected
16:46:47.998  I  The suppressing of SystemDialogs on the try #3 starts
16:46:50.164  I  The try #3 of the suppressing of SystemDialogs failed
16:46:50.221  I  The android system dialog/window was detected
16:46:50.222  I  The suppressing of SystemDialogs on the try #4 starts
16:46:50.621  I  Checking 'com.kaspersky.kaspresso.proxy.ViewAssertionProxy@195a905' assertion on view (view.getTag() "non-existent view")
16:46:50.621  I  (view.getTag() "non-existent view")
16:46:50.623  E  Failed to interact with view matching: (view.getTag() "non-existent view") because of NoMatchingViewException
16:46:50.760  I  The try #4 of the suppressing of SystemDialogs failed
16:46:52.249  I  The try #4 of the suppressing of SystemDialogs failed. The reason is the error is not allowed or android system dialog is suppressed but the error is existing
16:46:52.762  E  All attempts to interact for 10000 ms totally failed because of NoMatchingViewException
16:46:52.766  I  ---------------------------------------------------------------------------
16:46:52.767  I  AFTER TEST SECTION
16:46:52.768  I  ---------------------------------------------------------------------------
16:46:52.770  I  ---------------------------------------------------------------------------
16:46:52.770  I  TEST FAILED
16:46:52.771  I  ---------------------------------------------------------------------------
16:46:52.771  I  ___________________________________________________________________________
@AlexeyRybakov AlexeyRybakov added the bug Something isn't working label May 30, 2023
@primechord
Copy link

In our case, the test does not fail, but it takes longer

@AlexeyRybakov
Copy link
Author

In our case, the test does not fail, but it takes longer

You are right. But it could fail if you enable an AdbServer, than it will try to close a keyboard by a back action. The test would fail if you check that the keyboard is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants