I am trying to automate the "UI testing" for my android application by using firebase testlab. I have saved a script in android studio but want to limit the robot for any further monkey testing. All it does is after my sctipts runs successfully, it starts doing monkey testing, which is of no use to me.
I read it online it can be controlled using "maxDepth" but couldn't find anything more. Would appreciate if someone could help me implement this.
maxDepth was only supported by Robo v1. It has been deprecated and has not had any effect on Robo tests for a long time. The standard way to limit the length of a Robo test now is to use the timeout flag/option.
A possible(?) alternative would be to have your Robo script exit your app when it is done, but I have never tried that and am not sure how it would work.
Related
Every time I want to do a quick test of some code, android studio takes 20-40 minutes loading an emulator which then either crashes my laptop or makes it run very slow. Is there any way to just use the system log without loading the whole app, similar to the System.out.Prinln() feature in net beans?
I understand that the question is about running your app for quick testing and not about automated tests. But you can learn a lot by trying to adapt writing tests, and they can help you to solve your problem.
1) For code without android dependencies you can write JUnit tests and run those just on JVM to test the code. Bonus: you'll start with creating your testsuite!
2) For code with android dependencies: a) Try to be better in separating platform specific code and internal logic so you will be able to cover more code with unit tests. b) You can use roboelectric and test everything without emulator/device for the rest.
I'm struggling with instrumental ui test of a PlaceAutocomplete API, provided by Google.
What I'm trying to test is ability to open AutoComplete Activity (fired with proper button), enter some text, pick result from given list and check if picked position is listed on the recyclerview.
I'm trying to target this EditText below :(
with:
onView(withClassName(equalTo(EditText.class.getName())))
.inRoot(withDecorView(not(is(homeActivityActivityTestRule.getActivity().getWindow().getDecorView()))))
.perform(typeTextIntoFocusedView("kotek"), closeSoftKeyboard());
And other variations, like withText "Szukaj" or with com.google.android.gms.R.id :) without luck.
Help will be appreciated! Thank You!
This view is auto-generated by Google Api.
If it's true, sorry I haven't any experience with Places API, it would mean that Espresso is unable to find this view.
Solution: Espresso Test Recorder
You can install the latest Android Studio 2.2-RC2 (don't remove the previous) from: http://tools.android.com/download/studio/builds/2-2-rc to check brand new Espresso Test Recorder (check: http://tools.android.com/tech-docs/test-recorder) and try to get this view by click on this to generate code, but I said this might not help.
Solution: Espresso with uiatomator
My doubts about it come from Espresso framework limitation - it depends on actual context of app, it means that it may not recognize intents, genereated code or notifications.
Try to use typical instrumentation framework like Google's uiatomator. There's no problem to use it along with Espresso UI testing framework.
Read: http://qathread.blogspot.com/2015/05/espresso-uiautomator-perfect-tandem.html
More info you would find here: http://google.github.io/android-testing-support-%20/docs/uiautomator/
Solution: Espresso with Robotium or Robotium Test Recorder
If you find uiatomator a pretty hard to learn you can also use another instrumentation test framework called Robotium, which has clean and conchise syntax with some powerfull functions like taking screenshots.
It can work along with Espresso. Check last paragraph of this article: https://github.com/codepath/android_guides/wiki/UI-Testing-with-Robotium
It also has its own recorder: http://robotium.com/products/robotium-recorder. Try it for free, but I doubt that you would find it useful, as Robotium code is really simple to learn.
Hope it will help
Install Android studio 2.2 Beta, Try the Espresso test recorder. It will automatically generate an Espresso test case for you.
Try with this one :-
Espresso.onView(ViewMatchers.withId(R.id.places_autocomplete_edit_text))
.perform(ViewActions.typeText("<ADDRESS>"))
Thread.sleep(3000);
onView(withText("<ADDRESS FROM SUGESSION>"))
.inRoot(withDecorView(Matchers.not(activityTestRule.activity.window.decorView)))
.perform(click())
Tested with :- Android Studio:3.5.2 | espresso-core:3.1.1 | places:1.1.0
Autocompleater component seems to be not accessible using espresso, one solution is to send typing then clicking through a shell
getInstrumentation().getUiAutomation().executeShellCommand("input text n")
sleep(2000)
getInstrumentation().getUiAutomation().executeShellCommand("input tap " + Math.round(width / 2f) + " " + Math.round(height / 4f))
I'm using fastlane tools (https://fastlane.tools) for automating all screenshots for my iOS and Android apps. The tool works very well and I'm happy with it. The problem i'm having is that when I have mixpanel events and other analytics running on the app the app will run those events during screenshots. Is there a way to "detect" in code that it's a screenshot event with simulators?
Basically, I want some sort of if statement but not sure how to tell its from fastlane. I have thoroughly read through the documentation and wasn't able to find anything for this, any help is appreciated!
My current solution involves simply checking if the user is running on a simulator or is running in debug mode. In which case, it doesn't perform the code I want to filter out.
i'm trying to automate the settings in my android device(input wifi password, create account display setting etc) using uiautomator.
But the behaviour of the code is quite unpridictable.
Sometimes it works totally fine, and other time it give the following exception on the same device, under the same conditions.
INSTRUMENTATION_RESULT: shortMsg=java.lang.RuntimeException
INSTRUMENTATION_RESULT: LONGMsg=ChangeDisplaySetting ## this is the name of the class
INSTRUMENTATION_CODE: 0
m quite unable to figure out the reason. Also the code is quite large, and i dont know, which part shall i copy here.
Please guide.
Also it would be helpful, if there exits some other way(like some other language) of doing the same. I was studying about python, but i'm not sure, if it would perform all the functions on user mode.
Please guide.
You are welcome to try https://github.com/xiaocong/uiautomator. You can install it via pip install uiautomator, although it's under developing phase.
im thinking of an easy-to-use android usability testing tool, that will allow the user to record and log relevant information during app testing. As a first result i would like to have a screenshot taken each time the user interacts with the touchscreens where the position, duration and type of the touch event is shown.
As android does not allow me to take screenshots easily and as its not possible to log touchevents from an service here are my questions:
Does Logcat give me any information about TouchEvents (I tried but i couldt produce any touch-Logs)
Is it possible to evoke the ddms-Screenshot-action from terminal? (./ddms -takescreenshot)
Does Logcat give me any information about TouchEvents (I tried but i couldt produce any touch-Logs)
No.
Is it possible to evoke the ddms-Screenshot-action from terminal? (./ddms -takescreenshot)
Not via the ddms command AFAIK. Either use monkeyrunner (as another answer suggested), or write your own code to the JAR file that DDMS uses. I used that to create a software projector; another developer extended that concept.
If you are looking to automate these things, you can use the Monkey Runner tool, it specifically has a call to take screen shots automatically.
http://developer.android.com/guide/developing/tools/monkeyrunner_concepts.html
It specifically runs Python scripts, that you would use to design an automated regression test.