ldi-github / shirates-core

Integration test framework for mobile apps
https://ldi-github.github.io/shirates-core/
Apache License 2.0
8 stars 0 forks source link

Cannot select or tap a text due to a weird error #115

Closed Inovvia closed 2 weeks ago

Inovvia commented 2 weeks ago

Here is the code snippet: it.select("BDO Unibank, Inc.").tap()

Here is the error:

219 [00:01:14] 2024/09/19 10:36:37.119 {socialTestFunction-1} 0 - [operate] +2015 C (tap) Tap <BDO Unibank, Inc.> 220 [00:01:15] 2024/09/19 10:36:37.767 {socialTestFunction-1} 0 - [info] +648 C (tap) Syncing (1) 221 [00:01:15] 2024/09/19 10:36:37.877 {socialTestFunction-1} 0 - [info] +110 C (tap) Synced. (elapsed=0.11) 222 [00:01:15] 2024/09/19 10:36:37.890 {socialTestFunction-1} 0 - [ERROR] +13 C () For input string: "BDO Unibank, Inc."

Let me know if additional details are needed

Inovvia commented 2 weeks ago

Here are the logs and screenshot.

223 TestLog_20240919103522.log

ldi-github commented 2 weeks ago

Hi! Can you attach the source xml file (*.xml)?

Or you can debug to find the cause of the problem. Check following documents.

Watching sourceXML in file https://ldi-github.github.io/shirates-core/in_action/debugging/watching_source_xml_in_file.html

Watching sourceXML in debugger https://ldi-github.github.io/shirates-core/in_action/debugging/watching_source_xml_in_debugger.html

Inovvia commented 2 weeks ago

Sure here is the xml

`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>

`
ldi-github commented 2 weeks ago

Thanks.

I found your UI contains text that has trailing space.

text="BDO Unibank, Inc. "

Try this.

it.select("BDO Unibank, Inc. ").tap()

or

it.select("BDO Unibank, Inc.*").tap()

Inovvia commented 2 weeks ago

It still errors out. I actually tried that earlier.

Error Log: 180 [00:00:50] 2024/09/19 13:16:51.146 {socialTestFunction-1} 0 - [operate] +2021 C (tap) Tap <BDO Unibank, Inc.*> 181 [00:00:51] 2024/09/19 13:16:51.911 {socialTestFunction-1} 0 - [info] +765 C (tap) Syncing (1) 182 [00:00:51] 2024/09/19 13:16:52.027 {socialTestFunction-1} 0 - [info] +116 C (tap) Synced. (elapsed=0.116) 183 [00:00:51] 2024/09/19 13:16:52.041 {socialTestFunction-1} 0 - [ERROR] +14 C () For input string: "BDO Unibank, Inc." image

ldi-github commented 2 weeks ago

I tried to reproduce the error with this sample code. But could not.

` val XML = """ <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.widget.ScrollView> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.view.ViewGroup> </android.widget.FrameLayout> </android.widget.FrameLayout> </android.widget.LinearLayout> </android.widget.FrameLayout> """.trimIndent()

@Test
fun test1() {

    scenario {
        case(1) {
            TestElementCache.loadXml(XML)
            TestElementCache.synced = true
            it.select("BDO Unibank, Inc.*")
                .tap()
        }
    }
}

`

ldi-github commented 2 weeks ago

I would like to consider workaround.

How about followings?

it.tap("BDO Unibank, Inc.")

it.tap("<BDO Unibank, Inc.>:left")

Inovvia commented 2 weeks ago

Not sure what happened but your code worked! Thank you.

Would you be able to explain what "For input string" means?

ldi-github commented 2 weeks ago

That was good!

I think "For input string" is Java exception of parsing.

Example

    fun test1() {

        scenario {
            case(1) {
                "A".toInt()
            }
        }
    }
java.lang.NumberFormatException: For input string: "A"

    at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
    at java.base/java.lang.Integer.parseInt(Integer.java:668)
    at java.base/java.lang.Integer.parseInt(Integer.java:786)
...

I guess some error occurred in appium JavaClient because your TestLog_20240919103522.log has no stack trace information.

Check appiumYYYY-MM-DD_HHmmssfff.log if some error occurred at that time.

Inovvia commented 2 weeks ago

I think I found the issue now. I had this code after tapping and I was indeed trying to convert to floor the price I get. I guess it was selecting the period in "BDO Unibank, Inc."

val lastPrice = it.select("*.*")
            .getProperty("text")