agoda-com / Kakao

This repo is no longer supported. Please visit a https://github.com/KakaoCup/Kakao
Apache License 2.0
1.11k stars 102 forks source link

None of the following functions can be called with containsText() #198

Closed automaticqa closed 4 years ago

automaticqa commented 4 years ago

Hey there, guys! Please tell me, how to check a substring here:

fun isCustomViewDisplayed() {
            KTextView {              
                     withText(containsText(getResourceString(R.string.title).substringBefore("%")))
            }.isDisplayed()    
    }

I get an exception:

None of the following functions can be called with the arguments supplied: 
public final fun withText(@StringRes textId: Int): Unit defined in com.agoda.kakao.common.builders.ViewBuilder
public final fun withText(text: String): Unit defined in com.agoda.kakao.common.builders.ViewBuilder
public final fun withText(matcher: Matcher<String>): Unit defined in com.agoda.kakao.common.builders.ViewBuilder
Vacxe commented 4 years ago

Firstly try to define a value with val text = getResourceString(R.string.title).substringBefore("%")

After that u can try to call

 KTextView {              
                     withText(containsText(text))
            }.isDisplayed()  

It does not make sense to call containsText inside of withText

Cheers

Unlimity commented 4 years ago

Hi! You should not use withText matcher here in your case. withText is matcher that matches view with EXACT text provided. As far as I understand, what you need is:

KTextView {              
    containsText(getResourceString(R.string.title).substringBefore("%"))
}.isDisplayed()
automaticqa commented 4 years ago

Great! Thank you very much!