MonkeyTalk Android Detect String Containing \n for Button Tap - android

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!

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.

IN javascript you can use below command
app.button("buttonname").tap(x, y);

Use android:contentDesxription="your_component_id" in your view xml file definition or view.setContentDescription("your_component_id"); directly on view in code to make it easy to access in MonkeyTalk.

Related

I Want to use variable in cucumber feature file

There are scenarios in feature files wherein I've use the text "Foo" and on click its open a new page. this text sometime changes to "Foo1" or "Foo2" or to something else. to avoid line by line change in feature file for "Foo" to "Foo1" or "Foo2" is there any way that I can globally declare variable in top/bottom of the feature file where I can set the required text in variable on fly and I shall start executing my test instantly?
This change exist in many feature files and around 1000 lines in feature file. To get solution for this, I try on setting environment variables but I couldn't reach all the way till end this issue to solve. So can anyone help me on this?
Thanks in advance
What if you do the replacement in your step implementation instead? Then you could have the desired value in a separate file or pass it as arguments. That way you don't need to hard code the values.
Could scenario outlines help you in any way or is the value only changing depending on external changes?
My first thought was scenario outlines like #homaxto said.
Then I thought you might want to affect it by which system you are connected to. You can do this through configuration. I have done this with Fig_Newton.
You can either set an environment varaible or use one in the commandline. Or you can use #hook type tags. With a hook tag, you can have a tag at the top of a feature file that you can use to set a variable that affects how the steps operate (but it needs to be handled inside the step).

Masking Input in EditText in Android

How to use inputfilter for CNIC i.e #####-#######-# ? Please help me.. I am new to Android and I dont know how to use it?
How to mask input? I went through various sites but couldn't find solution. I am so confused.
Have you tried using Masked EditText ? This is what you want ... :)
If you want a numeric keyboard instead of alphabetical, then comment the following lineof code:
this.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
in the file MaskedEditText.java. Now setting android:inputType = "numeric" will work.
) You can also try the fork of Masked EditText. It's derived but with works with Gradle, has some bugfixes, an example project, and a little bit another behavior :-)
The behavior is also changed:
You can set the flag and the hint will be always visible.
Your pattern is invisible initially and grows automatically as soon, as you type. For instance, in the beginning, it is: "+7(", then you type '999' and it shows you "+7(999)" with another brace. In the original library, AFAIK it works like: "+7( ) - - ", then you type '999' and it transforms into "+7(999) - - " and so on.

My android app does not recognize R.string resources - what could be the reason?

I learn android with sample apps from textbook. In the given sample source R.string.something is recognized:
However, in my own EXACT source code, same R.strings are not recognized- highlighted as errors:
Does anyone know how to fix it?
I've had this many time with eclipse, and it was not a setup / code problem on my side. Generally, cleaning, rebuilding and sometime even stopping and restarting eclipse solved it. And yes, it's a pain in the neck ...
Try a clean of your project, if that does nothing then click on the problems tab and see if there's any build related issues, you may be missing a required jar or something!
These are following reason possible.
1-: You import android.R;
2-: Any error in xml files.
3-: Please check you String.xml file may be any error or declare a string more then two time.
I assume you are new to Android.
If so, there are two ways of using text strings in Buttons, textviews and so on:
1) Hardcoded string - you put the text you want in quotation marks (""), for example:
yourTextview.setText("Hardcoded string");
2) You can call the text from your String resources (res/values/strings.xml).
That is a much better approach seeing is is easier to translate, make changes and so on.
In your strings.xml file you can create all your string values, and call them from there.
Like in you example, if in your strings.xml file you have for example:
<string name="delete">This is String resource</string>
you can then call the string from there, like so :
yourTextview.setText(R.string.delete);
Hope this helps!

Calabash android output to HTML gives timeout errors when finding view elements

When running calabash-android and outputting to HTML format, I am getting intermittent exceptions as per the below (typically within the first step of the app). I am using Xamarin and MVVMCross libraries.
Timeout waiting for elements: * marked:'Terms of Use'
(Calabash::Android::WaitHelpers::WaitError)
./features/step_definitions/calabash_steps.rb:4:in `/^User has accepted the Terms of Use$/'
features\registration.feature:8:in `Given User has accepted the Terms of Use'
2
3Given /^User has accepted the Terms of Use$/ do
4 #current_page=page(TermsOfUse).await
5 #current_page.tap_accept_button
6end
7# gem install syntax to get syntax highlighting
The screenshots generated show the UI element is present on the screen, and the same errors never occur when I exclude the html format option and simply write the detail out to the console. Does anybody else have any experience of this?
Most likely the view's text has some formatting information in it.
It's a good practice to use id instead of text for identifying elements. If you have an id, use that:
query("* id:'terms_of_use_id'")
If you don't have an id try to add one.
If that is not possible try to query the whole UI with:
query("*")
Find the element and see what's in it's text property.

Tip Calculator App Issues

I've been working on the 'Tip Calculator' app for Android and I have a couple of questions.
I'm supposed to (in the process of creating the GUI) use some EditTexts to allow the user to enter the bill amount and read the calculated total bill. In the version I have, there is no EditText anywhere in the Visual Layout Editor, only CheckText. Are these the same?
Whenever I try to edit the Java code for the app, as per the book I have, I keep getting the message:
Thus and such is never used
For example, with
private static final String BILL_TOTAL = "BILL_TOTAL';
or anything from the import Android list, other than the one referring to a bundle. I'm Not sure how to resolve this. I have some experience with C and C++, but Java is new to me.
The warning that tells you that a variable or method or import is not used can be ignored, especially if you just haven't gotten to using it yet. It's a warning and not an error, so your app should compile regardless.
I don't know what you're using to build your layout (eclipse? I use Intellij Idea), but to add an EditText, you can edit the layout file by hand. Add a line similar to:
<EditText android:id="#+id/myEditText android:width="FILL_PARENT" android:height="WRAP_CONTENT"/>
As a general rule, I like to edit these things by hand. Then, when something breaks or doesn't work as I expect it to, I have some grasp of what's in there, and so I can usually fix it. The value gained by learning how to create a layout by hand easily offsets the value of the time that you'll save.
Good luck.

Categories

Resources