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

Unable to identify and typeText on the UIScreen elements using UITextEdit properties #216

Closed
mskumar1809 opened this issue Nov 13, 2020 · 5 comments · Fixed by #307
Closed

Comments

@mskumar1809
Copy link

mskumar1809 commented Nov 13, 2020

Hi there,

Below are the steps involved in my test

  1. Launch the app
  2. Locate and perform the action on the element in home screen (Native)
  3. The previous click actions navigates to the webview which is served by a different SDK
  4. This is a login screen which has username and password field

I was able to successfully identify the username and password fields using UIAutomator

 if(userNameTest.wait(Until.) && userName.isEnabled){
              uiDevice.wait(Until.findObject(By.res("com.android.chrome", "<ResourceID>")),DEFAULT_TIMEOUT)
               uiDevice.findObject(select.resourceId("IdentityLoginEmail")).setText("[email protected]")

But where as when I try to use the same identifiers in UIScreen implementation as below I am seeing errors as belo

class LoginScreen : UiScreen<LoginScreen>() {

    override val packageName: String = "com.android.chrome"

    val userName = UiEditText {
        withId("com.android.chrome","IdentityLoginEmail")
    }
}

Test

loginScreen {
                        flakySafely(DEFAULT_TIMEOUT) {
                            userName {
                            typeText("asnmshbdhdgfh")
                            }
                            password{
                                typeText("Password1234$")
                            }
                            loginButton{
                                isDisplayed()
                                isClickable()
                                click()
                            }
                        }
                    }

Error log:

com.kaspersky.components.kautomator.intercept.exception.UnfoundedUiObjectException: The UiObject2 was not found on the screen. The selector=BySelector [PKG='\Qcom.android.chrome\E', RES='\Qcom.android.chrome:id/IdentityLoginEmail\E'], index=0
	at com.kaspersky.components.kautomator.intercept.interaction.UiObjectInteraction.perform(UiObjectInteraction.kt:40)
	at com.kaspersky.kaspresso.interceptors.tolibrary.kautomator.KautomatorObjectInterceptor$interceptPerform$1.invoke(KautomatorObjectInterceptor.kt:49)
	at com.kaspersky.kaspresso.interceptors.tolibrary.kautomator.KautomatorObjectInterceptor$interceptPerform$1.invoke(KautomatorObjectInterceptor.kt:13)
	at com.kaspersky.kaspresso.autoscroll.ObjectAutoScrollProviderImpl.withAutoScroll(ObjectAutoScrollProviderImpl.kt:30)
	at com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.autoscroll.AutoScrollObjectBehaviorInterceptor.withAutoScroll(Unknown Source:12)
	at com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.autoscroll.AutoScrollObjectBehaviorInterceptor.interceptPerform(AutoScrollObjectBehaviorInterceptor.kt:44)
	at com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.autoscroll.AutoScrollObjectBehaviorInterceptor.interceptPerform(AutoScrollObjectBehaviorInterceptor.kt:16)
	at com.kaspersky.kaspresso.interceptors.tolibrary.kautomator.KautomatorObjectInterceptor$interceptPerform$$inlined$fold$lambda$1.invoke(KautomatorObjectInterceptor.kt:53)
	at com.kaspersky.kaspresso.interceptors.tolibrary.kautomator.KautomatorObjectInterceptor$interceptPerform$$inlined$fold$lambda$1.invoke(KautomatorObjectInterceptor.kt:13)
	at com.kaspersky.kaspresso.uiobjectloader.UiObjectLoaderProviderImpl.handleUiObjectAbsence(UiObjectLoaderProviderImpl.kt:32)
	at com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.loader.UiObjectLoaderBehaviorInterceptor.handleUiObjectAbsence(Unknown Source:12)
	at com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.loader.UiObjectLoaderBehaviorInterceptor.interceptPerform(UiObjectLoaderBehaviorInterceptor.kt:44)
	at com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.loader.UiObjectLoaderBehaviorInterceptor.interceptPerform(UiObjectLoaderBehaviorInterceptor.kt:15)
	at com.kaspersky.kaspresso.interceptors.tolibrary.kautomator.KautomatorObjectInterceptor$interceptPerform$$inlined$fold$lambda$1.invoke(KautomatorObjectInterceptor.kt:53)
	at com.kaspersky.kaspresso.interceptors.tolibrary.kautomator.KautomatorObjectInterceptor$interceptPerform$$inlined$fold$lambda$1.invoke(KautomatorObjectInterceptor.kt:13)
	at com.kaspersky.kaspresso.systemsafety.SystemDialogSafetyProviderImpl.passSystemDialogs(SystemDialogSafetyProviderImpl.kt:51)
	at com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.systemsafety.SystemDialogSafetyObjectBehaviorInterceptor.passSystemDialogs(Unknown Source:7)
	at com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.systemsafety.SystemDialogSafetyObjectBehaviorInterceptor.interceptPerform(SystemDialogSafetyObjectBehaviorInterceptor.kt:48)
	at com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.systemsafety.SystemDialogSafetyObjectBehaviorInterceptor.interceptPerform(SystemDialogSafetyObjectBehaviorInterceptor.kt:17)
	at com.kaspersky.kaspresso.interceptors.tolibrary.kautomator.KautomatorObjectInterceptor$interceptPerform$$inlined$fold$lambda$1.invoke(KautomatorObjectInterceptor.kt:53)
	at com.kaspersky.kaspresso.interceptors.tolibrary.kautomator.KautomatorObjectInterceptor$interceptPerform$$inlined$fold$lambda$1.invoke(KautomatorObjectInterceptor.kt:13)
	at com.kaspersky.kaspresso.interceptors.tolibrary.kautomator.KautomatorObjectInterceptor.interceptPerform(KautomatorObjectInterceptor.kt:55)
	at com.kaspersky.kaspresso.interceptors.tolibrary.LibraryInterceptorsInjector$injectKaspressoInKautomator$1$1$2.invoke(LibraryInterceptorsInjector.kt:87)
	at com.kaspersky.kaspresso.interceptors.tolibrary.LibraryInterceptorsInjector$injectKaspressoInKautomator$1$1$2.invoke(LibraryInterceptorsInjector.kt:22)
	at com.kaspersky.components.kautomator.intercept.delegate.UiDelegate$DefaultImpls.interceptOnPerform(UiDelegate.kt:68)
	at com.kaspersky.components.kautomator.intercept.delegate.UiDelegate$DefaultImpls.access$interceptOnPerform(UiDelegate.kt:13)
	at com.kaspersky.components.kautomator.intercept.delegate.UiDelegate$interceptPerform$1.invoke(UiDelegate.kt:44)
	at com.kaspersky.components.kautomator.intercept.delegate.UiDelegate$DefaultImpls.interceptPerform(UiDelegate.kt:49)
	at com.kaspersky.components.kautomator.intercept.delegate.UiObjectInteractionDelegate.interceptPerform(UiObjectInteractionDelegate.kt:22)
	at com.kaspersky.components.kautomator.intercept.delegate.UiObjectInteractionDelegate.interceptPerform(UiObjectInteractionDelegate.kt:22)
	at com.kaspersky.components.kautomator.intercept.delegate.UiObjectInteractionDelegate.perform(UiObjectInteractionDelegate.kt:62)
	at com.kaspersky.components.kautomator.intercept.delegate.UiObjectInteractionDelegate.perform(UiObjectInteractionDelegate.kt:48)
	at com.kaspersky.components.kautomator.component.edit.UiEditableActions$DefaultImpls.typeText(UiEditableActions.kt:18)
	at com.kaspersky.components.kautomator.component.edit.UiEditText.typeText(UiEditText.kt:15)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3$2$3$1$1.invoke(UserCheckoutTest.kt:84)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3$2$3$1$1.invoke(UserCheckoutTest.kt:19)
	at com.kaspersky.components.kautomator.component.common.views.UiBaseView.invoke(UiBaseView.kt:54)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3$2$3$1.invoke(UserCheckoutTest.kt:83)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3$2$3$1.invoke(UserCheckoutTest.kt:19)
	at com.kaspersky.kaspresso.flakysafety.algorithm.FlakySafetyAlgorithm.invokeFlakySafely(FlakySafetyAlgorithm.kt:32)
	at com.kaspersky.kaspresso.flakysafety.FlakySafetyProviderGlobalImpl.flakySafely(FlakySafetyProviderGlobalImpl.kt:94)
	at com.kaspersky.kaspresso.testcases.core.testcontext.BaseTestContext.flakySafely(Unknown Source:12)
	at com.kaspersky.kaspresso.flakysafety.FlakySafetyProvider$DefaultImpls.flakySafely$default(FlakySafetyProvider.kt:32)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3$2$3.invoke(UserCheckoutTest.kt:82)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3$2$3.invoke(UserCheckoutTest.kt:19)
	at com.kaspersky.components.kautomator.screen.UiScreen.invoke(UiScreen.kt:107)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3$2.invoke(UserCheckoutTest.kt:81)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3$2.invoke(UserCheckoutTest.kt:19)
	at com.kaspersky.kaspresso.testcases.core.testcontext.TestContext.step(TestContext.kt:38)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3.invoke(UserCheckoutTest.kt:53)
	at thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest$onOrderPlacementOrderIdShouldBeGenerated$3.invoke(UserCheckoutTest.kt:19)
	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 thor.zopsmart.com.thor.kaspresso.tests.UserCheckoutTest.onOrderPlacementOrderIdShouldBeGenerated(UserCheckoutTest.kt:46)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at androidx.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:531)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	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:392)
	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2189)

Tests ran to completion.

Kindly please help here.

@mskumar1809 mskumar1809 changed the title Unable to identify the UIScreen elements using UITextEdit propertied Unable to identify the UIScreen elements using UITextEdit properties Nov 13, 2020
@mskumar1809 mskumar1809 changed the title Unable to identify the UIScreen elements using UITextEdit properties Unable to identify and typeText on the UIScreen elements using UITextEdit properties Nov 13, 2020
@matzuk
Copy link
Member

matzuk commented Nov 30, 2020

Hi @mskumar1809!
Is this issue actual? =)

@matzuk
Copy link
Member

matzuk commented Feb 1, 2021

Looks outdated.
@mskumar1809 be free to clarify =)

@matzuk matzuk closed this as completed Feb 1, 2021
@ghost
Copy link

ghost commented Feb 2, 2021

@matzuk Hi! I have exactly the same issue. Not sure if @mskumar1809 was able to resolve it.

In my case it has the same error:

E/TestRunner: com.kaspersky.components.kautomator.intercept.exception.UnfoundedUiObjectException: The UiObject2 was not found on the screen. The selector=BySelector [RES='\Qcom.android.chrome:id/email\E'], index=0

The same test will pass using a plain UIAutomator. Any ideas what it can be?

@matzuk matzuk reopened this Feb 4, 2021
@VarshaBhatiaPapershift
Copy link

Having the similar issue

    @Test
    fun mustOpenRegisterPageFromWelcomePageTest() {
        setupEnvironment().run {
            WelcomeScreen {
                takeScreenshot("Welcome Screen")
                this.welcomeText.containsText(context.getString(R.string.welcome_view_title))
            }
        }
    }
    -----------
    object WelcomeScreen : BaseTerminalScreen<WelcomeScreen>() {
    override val layoutId: Int
        get() = R.layout.fragment_welcome
    override val viewClass: Class<*>
        get() = WelcomeFragment::class.java
    val welcomeText = UiTextView {
        this.withId([email protected], "headerTextView")
    }
}```

Error:

com.kaspersky.components.kautomator.intercept.exception.UnfoundedUiObjectException: The UiObject2 was not found on the screen. The selector=BySelector [RES='\Qcom.papershift.terminal.delta:id/headerTextView\E'], index=0

Verion kaspresso = '1.2.1'

@matzuk
Copy link
Member

matzuk commented Jun 17, 2021

@pp-gtroshin @VarshaBhatiaPapershift Hi!
Can you prepare a simple example to produce this bug? It would help a lot to determine the root cause.

@matzuk matzuk closed this as completed Oct 17, 2021
@matzuk matzuk reopened this Oct 17, 2021
@matzuk matzuk linked a pull request Nov 7, 2021 that will close this issue
5 tasks
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

Successfully merging a pull request may close this issue.

3 participants