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

checking the initial state of app with progressbar #264

Closed
TheReprator opened this issue Jun 22, 2021 · 7 comments
Closed

checking the initial state of app with progressbar #264

TheReprator opened this issue Jun 22, 2021 · 7 comments

Comments

@TheReprator
Copy link

Hi Team,

Actually i am trying to test the initial state of app, where app is in loading state but whenever i run the test in throws me following error, as follows,

Exception:
junit.framework.AssertionFailedError: 'is displayed on the screen to the user' doesn't match the selected view.
Expected: is displayed on the screen to the user
Got: "ProgressBar{id=2131230934, res-name=lee_progress, visibility=GONE, width=96, height=96, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@f29348d, tag=null, root-is-layout-requested=false, has-input-connection=false, x=312.0, y=676.0}"

at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1720)
at com.kaspersky.kaspresso.failure.FailureLoggingProviderImpl.describedWith(FailureLoggingProviderImpl.kt:91)
at com.kaspersky.kaspresso.failure.FailureLoggingProviderImpl.logDescriptionAndThrow(FailureLoggingProviderImpl.kt:69)
at com.kaspersky.kaspresso.failure.LoggingFailureHandler.logDescriptionAndThrow(Unknown Source:2)
at com.kaspersky.kaspresso.failure.LoggingFailureHandler.handle(LoggingFailureHandler.kt:21)
at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:103)
at androidx.test.espresso.ViewInteraction.check(ViewInteraction.java:31)
at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptCheck$1.invoke(KakaoViewInterceptor.kt:29)
at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptCheck$1.invoke(KakaoViewInterceptor.kt:16)
at com.kaspersky.kaspresso.autoscroll.AutoScrollProviderImpl.withAutoScroll(AutoScrollProviderImpl.kt:30)
at com.kaspersky.kaspresso.interceptors.behavior.impl.autoscroll.AutoScrollViewBehaviorInterceptor.withAutoScroll(Unknown Source:12)
at com.kaspersky.kaspresso.interceptors.behavior.impl.autoscroll.AutoScrollViewBehaviorInterceptor.intercept(AutoScrollViewBehaviorInterceptor.kt:26)
at com.kaspersky.kaspresso.interceptors.behavior.impl.autoscroll.AutoScrollViewBehaviorInterceptor.intercept(AutoScrollViewBehaviorInterceptor.kt:14)
at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptCheck$$inlined$fold$lambda$1.invoke(KakaoViewInterceptor.kt:34)
at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptCheck$$inlined$fold$lambda$1.invoke(KakaoViewInterceptor.kt:16)
at com.kaspersky.kaspresso.systemsafety.SystemDialogSafetyProviderImpl.passSystemDialogs(SystemDialogSafetyProviderImpl.kt:51)
at com.kaspersky.kaspresso.interceptors.behavior.impl.systemsafety.SystemDialogSafetyViewBehaviorInterceptor.passSystemDialogs(Unknown Source:7)
at com.kaspersky.kaspresso.interceptors.behavior.impl.systemsafety.SystemDialogSafetyViewBehaviorInterceptor.intercept(SystemDialogSafetyViewBehaviorInterceptor.kt:28)
at com.kaspersky.kaspresso.interceptors.behavior.impl.systemsafety.SystemDialogSafetyViewBehaviorInterceptor.intercept(SystemDialogSafetyViewBehaviorInterceptor.kt:15)
at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptCheck$$inlined$fold$lambda$1.invoke(KakaoViewInterceptor.kt:34)
at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptCheck$$inlined$fold$lambda$1.invoke(KakaoViewInterceptor.kt:16)
at com.kaspersky.kaspresso.flakysafety.algorithm.FlakySafetyAlgorithm.invokeFlakySafely(FlakySafetyAlgorithm.kt:32)
at com.kaspersky.kaspresso.flakysafety.algorithm.FlakySafetyAlgorithm.invokeFlakySafely$default(FlakySafetyAlgorithm.kt:24)
at com.kaspersky.kaspresso.flakysafety.FlakySafetyProviderSimpleImpl.flakySafely(FlakySafetyProviderSimpleImpl.kt:27)
at com.kaspersky.kaspresso.interceptors.behavior.impl.flakysafety.FlakySafeViewBehaviorInterceptor.flakySafely(Unknown Source:7)
at com.kaspersky.kaspresso.interceptors.behavior.impl.flakysafety.FlakySafeViewBehaviorInterceptor.intercept(FlakySafeViewBehaviorInterceptor.kt:26)
at com.kaspersky.kaspresso.interceptors.behavior.impl.flakysafety.FlakySafeViewBehaviorInterceptor.intercept(FlakySafeViewBehaviorInterceptor.kt:14)
at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptCheck$$inlined$fold$lambda$1.invoke(KakaoViewInterceptor.kt:34)
at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor$interceptCheck$$inlined$fold$lambda$1.invoke(KakaoViewInterceptor.kt:16)
at com.kaspersky.kaspresso.interceptors.tolibrary.kakao.KakaoViewInterceptor.interceptCheck(KakaoViewInterceptor.kt:36)
at com.kaspersky.kaspresso.interceptors.tolibrary.LibraryInterceptorsInjector$injectKaspressoInKakao$1$1$1.invoke(LibraryInterceptorsInjector.kt:54)
at com.kaspersky.kaspresso.interceptors.tolibrary.LibraryInterceptorsInjector$injectKaspressoInKakao$1$1$1.invoke(LibraryInterceptorsInjector.kt:22)
at io.github.kakaocup.kakao.delegate.Delegate$DefaultImpls.interceptOnCheck(Delegate.kt:61)
at io.github.kakaocup.kakao.delegate.Delegate$DefaultImpls.access$interceptOnCheck(Delegate.kt:13)
at io.github.kakaocup.kakao.delegate.Delegate$interceptCheck$1.invoke(Delegate.kt:28)
at io.github.kakaocup.kakao.delegate.Delegate$DefaultImpls.interceptCheck(Delegate.kt:33)
at io.github.kakaocup.kakao.delegate.ViewInteractionDelegate.interceptCheck(ViewInteractionDelegate.kt:21)
at io.github.kakaocup.kakao.delegate.ViewInteractionDelegate.interceptCheck(ViewInteractionDelegate.kt:21)
at io.github.kakaocup.kakao.delegate.ViewInteractionDelegate.check(ViewInteractionDelegate.kt:26)
at io.github.kakaocup.kakao.common.assertions.BaseAssertions$DefaultImpls.isDisplayed(BaseAssertions.kt:36)
at io.github.kakaocup.kakao.common.views.KBaseView.isDisplayed(KBaseView.kt:34)
at reprator.wipro.factlist.test.FactListKaspressoTest$initialScreenTest$3$1$1$1.invoke(FactListKaspressoTest.kt:62)
at reprator.wipro.factlist.test.FactListKaspressoTest$initialScreenTest$3$1$1$1.invoke(FactListKaspressoTest.kt:20)
at io.github.kakaocup.kakao.common.views.KBaseView.invoke(KBaseView.kt:83)
at reprator.wipro.factlist.test.FactListKaspressoTest$initialScreenTest$3$1$1.invoke(FactListKaspressoTest.kt:61)
at reprator.wipro.factlist.test.FactListKaspressoTest$initialScreenTest$3$1$1.invoke(FactListKaspressoTest.kt:20)
at io.github.kakaocup.kakao.screen.Screen.invoke(Screen.kt:119)
at reprator.wipro.factlist.test.FactListKaspressoTest$initialScreenTest$3$1.invoke(FactListKaspressoTest.kt:59)
at reprator.wipro.factlist.test.FactListKaspressoTest$initialScreenTest$3$1.invoke(FactListKaspressoTest.kt:20)
at com.kaspersky.kaspresso.testcases.core.testcontext.TestContext.step(TestContext.kt:39)
at reprator.wipro.factlist.test.FactListKaspressoTest$initialScreenTest$3.invoke(FactListKaspressoTest.kt:56)
at reprator.wipro.factlist.test.FactListKaspressoTest$initialScreenTest$3.invoke(FactListKaspressoTest.kt:20)
at com.kaspersky.kaspresso.testcases.core.TestRunner.runMainTestSection(TestRunner.kt:144)
at com.kaspersky.kaspresso.testcases.core.TestRunner.run(TestRunner.kt:58)
at com.kaspersky.kaspresso.testcases.core.sections.MainTestSection.run(MainTestSection.kt:29)
at reprator.wipro.factlist.test.FactListKaspressoTest.initialScreenTest(FactListKaspressoTest.kt:55)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
at androidx.test.internal.runner.junit4.statement.RunAfters.evaluate(RunAfters.java:61)
at dagger.hilt.android.internal.testing.MarkThatRulesRanRule$1.evaluate(MarkThatRulesRanRule.java:106)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:395)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2198)

Caused by: junit.framework.AssertionFailedError: 'is displayed on the screen to the user' doesn't match the selected view.
Expected: is displayed on the screen to the user
Got: "ProgressBar{id=2131230934, res-name=lee_progress, visibility=GONE, width=96, height=96, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@f29348d, tag=null, root-is-layout-requested=false, has-input-connection=false, x=312.0, y=676.0}"

at androidx.test.espresso.matcher.ViewMatchers.assertThat(ViewMatchers.java:17)
at androidx.test.espresso.assertion.ViewAssertions$MatchesViewAssertion.check(ViewAssertions.java:15)
at com.kaspersky.kaspresso.proxy.ViewAssertionProxy.check(ViewAssertionProxy.kt:26)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAssertion.check(ViewInteraction.java:10)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:11)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:2)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:914)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:225)
at android.app.ActivityThread.main(ActivityThread.java:7563)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994)

Repository:
https://github.com/TheReprator/Wipro/blob/initial_state_test/appModules/factList/src/androidTest/kotlin/reprator/wipro/factlist/test/FactListKaspressoTest.kt

Test Name: initialScreenTest

Kindly assist.

Regards,
Vikram Singh

@matzuk
Copy link
Member

matzuk commented Jun 28, 2021

Hi @TheReprator!
I think this question is related to Kakao. @Vacxe can you give advice? =)

@Vacxe
Copy link
Contributor

Vacxe commented Jun 29, 2021

@TheReprator

As you can see in logs

Got: "ProgressBar{id=2131230934, res-name=lee_progress, visibility=GONE, width=96, height=96, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@f29348d, tag=null, root-is-layout-requested=false, has-input-connection=false, x=312.0, y=676.0}

Got: "ProgressBar{id=2131230934 .. visibility=GONE, thats why isDisplayed() failing.

As advice:

U starting mockWebServer.start(8080) and probably the issue related for race condition. Here we don't have Kakao related issues at all. Something with wrong test configuration

@TheReprator
Copy link
Author

Ok, but it will be great, if you can further assist me with my code, as i had already put idealregistery in my code. But still it didn't wait for it.

@Vacxe
Copy link
Contributor

Vacxe commented Jun 29, 2021

@TheReprator can we close this issue?
We can assist you with library related issues. For other questions please use StackOverFlow

@TheReprator
Copy link
Author

Can we put an effort on it, to sort this issue, i know, it might not be related to this framework, but as a developer i need ur assistance to sort this issue out.

@TheReprator
Copy link
Author

Even after chaniging my code to this, `package reprator.wipro.factlist.test

import androidx.test.espresso.IdlingRegistry
import com.jakewharton.espresso.OkHttp3IdlingResource
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import reprator.wipro.factlist.Factlist
import reprator.wipro.factlist.dispatcherWithCustomBody
import reprator.wipro.factlist.screen.FactListKaspressoScreen
import reprator.wipro.factlist.util.launchFragmentInHiltContainer
import javax.inject.Inject

@HiltAndroidTest
class FactListKaspressoTest : TestCase() {

@get:Rule(order = 0)
var hiltRule = HiltAndroidRule(this)

private val mockWebServer = MockWebServer()

@Inject
lateinit var okHttp3IdlingResource: OkHttp3IdlingResource

@Before
fun setUp() {
    hiltRule.inject()

    IdlingRegistry.getInstance().register(okHttp3IdlingResource)

    launchFragmentInHiltContainer<Factlist>()
}

@After
fun cleanup() {
    mockWebServer.close()
    IdlingRegistry.getInstance().unregister(okHttp3IdlingResource)
}

@Test
fun initialScreenTest() =
    before {
        testLogger.i("Before section initial test")
    }.after {
        testLogger.i("After section initial test")
    }.run {
        step("1. show loading") {

            FactListKaspressoScreen {

                progress {
                    isDisplayed()
                }

                mockWebServer.start(8080)
                mockWebServer.dispatcher = dispatcherWithCustomBody()

            }
        }

        step("2. verify recyclerview") {

            FactListKaspressoScreen {
                factList {
                    hasSize(14)
                    isDisplayed()
                }
            }
        }
    }

}

is not working`

@Vacxe
Copy link
Contributor

Vacxe commented Jun 30, 2021

@TheReprator as I mentioned before, for investigation you can use any sort of tooling such as Debugger or etc. We maintaining those OSS project on volunteered intensions and unfortunately we don't have time capacity to help you with this issue. However, you can try to create a ticket on StackOverFlow for further assistance from open source community.

The samples of your code don't tell me nothing about issue and I can't see the whole problem. Because it can be lack of implementation on ANY layer

If you decided to use our framework that's doesn't means that we will assist you with any problem in your code. You always can roll back to pure Espresso


Also "As a developer" - you should investigate the root of issue. Please don't be obsessive. Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants