Uiautomator - takeScreenshot - is there a way to store the image on the machine running the tests instead of the device - android-uiautomator

In a uiautomator test, using takeScreenshot(), is there a way to store the image on the machine running the tests instead of the device?
If it cant be done with takeScreenshot, id be interested in hearing any alternative methods anyone has come up with.
Thanks

You could define a store path (screenPath) and save the screenshot on the device.
The you could use adb pull like this:
adb pull screenPath localPath
To copy the screenshot locally.

Not yet fully covering all UiAutomator cases but AndroidViewClient/culebra could give you an alternative. You may replace some of your tests and take screenshots and they will be saved on the machine running the tests.
There's a extremely simple way of generating test cases using Culebra GUI, just run:
$ culebra -UG -o mytest.py
to generate a test case. Then, during the test generation, you can use CTRL+F (or the context menu) and the screenshot will be saved and a line like this
self.vc.writeImageToFile('/tmp/${serialno}-${focusedwindowname}-${timestamp}.png', 'PNG')
will be generated in the test script, so everytime you run it will be saved without overriting the previous one.
Hope this helps.

Related

Is there a recommended debugging strategy for E2E automation tests?

What is the best elegant approach for debugging a large E2E test?
I am using TestCafe automation framework and currently. I'm facing multiple tests that are flaky and require a fix.
The problem is that every time I modify something within the test code I need to run the entire test from the start in order to see if that new update succeeds or not.
I would like to hear ideas about strategies regard to how to debug an E2E test without losing your mind.
Current debug methods:
Using the builtin TestCafe mechanism for debugging in the problematic area in the code and try to comment out everything before that line.
But that really doesn't feel like the best approach.
When there are prerequisite data such as user credentials,url,etc.. I manually Declare those again just before the debug().
PS: I know that tests should be focused as much as possible and relatively small but this is what we have now.
Thanks in advance
You can try using the flag
--debug-on-fail
This pauses the test when it fails and allows you to view the tested page and determine the cause of the fail.
Also use test.only to to specify that only a particular test or fixture should run while all others should be skipped
https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html#--debug-on-fail
You can use the takeScreenshot action to capture the existing state of the application during the test. Test Café stores the screenshots inside the screenshots sub-directory and names the file with a timestamp. Alternatively, you can add the takeOnFails command line flag to automatically capture the screen whenever a test fails, so at the point of failure.
Another option is to slow down the test so it’s easier to observe when it is running. You can adjust the speed using the - speed command line flag. 1 is the fastest speed and 0.01 the slowest. Then you can record the test run using the - video command line flag, but you need to set up FFmpeg for this.

How do you write UI tests for a command line app in Xcode?

I'm making a small Zork-type game, and I don't want to have to type my way through the whole thing to test the game play every time I change something. Is there a way to use UI testing to do it for me?
I've tried looking around, but everyone just talks about running UI tests from the command line. But, I'd like to know how to do it for a console app.
Now I don't know what your codebase looks like, but your best bet is probably to create test files that run the logic you want to test. You may want to make all logic input independent so that input can be passed by either your tests or a user.

When running simulations in Veins, can one dump the Console Output into a file

I am currently running Simulations in Veins and/or Artery.
Is there an easy way (thats perhaps I just didn't find because I'm blind/stupid) to dump the Output created in the Console into a file, apart from running it slower than express mode and then using copy/paste?
Can I create these data while still running in express-mode?
The short answer: if by 'console output' you mean the event log, then yes you can, but no you shouldn't, for exactly the reason you mention: express mode disables this output.
The recommended way to collect data from your simulation is by recording it using "statistics", see also this page of the OMNeT++ tutorial.
You can log this information using the record-eventlog=true option in your omnetpp.ini (as described in more detail in the manual), but this produces huge files for veins and artery. This is because the event log is used more as a logging system. The best way to think of it is as debug output and development support: to quickly figure out why something isn't working correctly. I tried to (ab)use this feature for logging data -- please, save yourself the immense pains and use the statistics module.
Yes. Easiest way, From top bar, go to: Run > Run Configuration > Common tab > scroll down to output and select the name and the location of the output file.
Downside, each time you want to run a different application, it over writes the previous one that was created, so don't forget to back it up before you run a different simulation.
Good luck.

run Xcode project tests from terminal

I am quite curious to know if there is a way to achieve the same that you get, when in Xcode you press cmd-u (or select Test from the menu).
I am writing some UI tests for an application, and would love to automate the whole thing.
So far, any attempt to automate via applescript has been quite unsuccessful (I told myself how hard it is to simulate 2 button pressed...); so I thought that maybe there is a proper way to just run the command line commands and have the simulator to pop and run the tests, like it does in Xcode.
Altho if this function was known, I would find something online, but it seems that there is no way to simulate the test command via console.
Am I missing something?
Have you checked out the xcodebuild command?
The man page says:
buildaction ...
Specify a build action (or actions) to perform on the target. Available build actions are:
test Test a scheme from the build root (SYMROOT). This requires specifying a scheme.
So, perhaps that will do what you want.

How do I Log selenium RC output

I have a test hub .Net application which can fire off different selenium tests.
I'm looking for a good way to record the results of that specific test and tell the user if there has been an error.
I've added the "-log selenium.log -browserSideLog line" but, can I access the log programatically?
The idea being that at the tear down stage I can look at the entries and search for "Error" and report this to the user.
I know there is the "RetrieveLastRemoteControlLogs" command but that only gets part of log.
if you know PowerShell, then you can to use cmdlet get-content.
In .Net you can to use methods from the class File MSDN, but i dont work with it.
you can run "get-content" after each test and check whether there are errors
if i have not answered your question, then you can add tags, because it is not only selenium-rc`s question.

Resources