Search code examples
androidbuttonspecial-charactersmonkeytalk

MonkeyTalk Android Detect String Containing \n for Button Tap


I am using MonkeyTalk to automate some user test cases for my Android app. Everything is working fine except for when I try and detect a button containing this string:

"Connect\n(Code Required)"

I get this error:

FAILURE: Unable to find Button(Connect\n(Code required))

If I change the button to "Connect" and perform a tap on that value MonkeyTalk has no trouble, but something about the line break must be throwing it off.

After some searching I found this thread that confirmed my suspicious about the line break. There was one suggested fix here, to set the default encoding to UTF-8 (Select the Project > File > Properties > Resources)

However this did not work for me.

I have also tried to find the button using a wildcard like so:

"*(Code Required)"

But this does not seem to be supported either.

Maybe there is an alternative line break character I could use?

Thanks in advance for the help!


Solution

  • Maybe there's a carriage return in there? I know in most text editors a new line actually consists of (carriage return)+(newline).

    Also take a look at this: TextView carriage return not working

    Also, depending on how flexible your requirements are, you could use the #N MonkeyId replacement to get the Nth button.