I'm writing automated tests for our Android and iOS apps and I was wondering if there was an interactive shell in python for appium where you can run the app you are testing against and query the screen for certain elements. I know you can use 'arc' in ruby that let's you query the screen on the device for certain elements, but I can't find anything similar for python.
Related
I am using appium_libto automate my tests in both iOS and Android
Currently, I am maintaining two suites, one for android seperately and another for iOS.
Is there a provision in this cucumber with appium_lib gem, to maintain the cases for both iOS and Android both in a single suite? And let appium automatically detect which device is connected, and execute the test cases tagged accordingly?
Like if Appium detects it to be iOS, run the test cases that are tagged under iOS cucumber -t #ios
I understand env.rb could be of help in this and in hooks.rb under before do I could provide a if and else condition with
if $driver.device_is_android? == 'true'
'cucumber -t #Android'
else
'cucumber -t #iOS'
end
Something like this? Is it possible? I am unable to find information on the internet with respect to auto detect of device OS, and hence posted this as a question with my thoughts.
I understand I can read the versions of the OS with the command adb shell getprop | grep build.version.release , and hence wanted to know if its possible to read the OS with one common command, apart from $driver.device_is_android?
Now to run the cucumber cases, for iOS and Android, I need to pass individual capabilities in appium. Is there a way to do it programmatically in the if and else condition itself?
I also ran into this dilema but I solved differently.
In our case we are using Cucumber on top of Appium so I just execute it with an argument that represents my platform, for example:
cucumber PLATFORM=iOS
Then in my env.rb I get the argument:
#platform = ENV['PLATFORM']
And then I just use it to get the capabilities I want:
if #platform == "DROID"
Appium::Driver.new(droid_caps, true)
else
Appium::Driver.new(ios_caps, true)
end
When you are running a test you always know which platform you are testing so it makes sense to send it as an argument.
I was wondering if there is any way to progam automated touch events? For example, I have my android app and I want to make a program where automatically make 100 tests and every test makes touch events depending on what appears on the app. And I would like to do this on emulators, if is possible all 100 test at the same time.
for exercising your app with many (more than 100 events) use monkey (Full name: UI/Application Exerciser Monkey) or/and monkeyrunner.
The Monkey is a command-line tool that you can run on any emulator
instance or on a device. It sends a pseudo-random stream of user
events into the system, which acts as a stress test on the application
software you are developing.
The Monkey includes a number of options, but they break down into four
primary categories:
Basic configuration options, such as setting the number of events to
attempt.
Operational constraints, such as restricting the test to a single package.
Event types and frequencies.
Debugging options.
Site: http://developer.android.com/intl/es/tools/help/monkey.html
Basic using:
$ adb shell monkey [options] <event-count>
Example
adb shell monkey -p your.package.name -v 500
So if you want to take control over Android system events and you're familiar with Python and writing testing scripts, then you can use monkeyrunner.
The monkeyrunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code.
With monkeyrunner, you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation.
The monkeyrunner tool is primarily designed to test applications and devices at the functional/framework level and for running unit test suites, but you are free to use it for other purposes.
Documentation: http://developer.android.com/intl/es/tools/help/monkeyrunner_concepts.html
NOTE: The monkeyrunner tool is not related to the I/Application Exerciser Monkey, also known as the monkey tool. The monkey tool runs in an adb shell directly on the device or emulator and generates pseudo-random streams of user and system events. In comparison, the monkeyrunner tool controls devices and emulators from a workstation by sending specific commands and events from an API.
At this moment I have a script written in AutoIt that browses some websites to check if it's online and forward some information via e-mail, but because of AutoIt only works on a "real computer", I can't put it in some "low-powered" device like a Mini Android PC or Raspberry Pi.
What I want to know is if there is some program or programming language where I can do the same thing in Android PC or Raspberry Pi.
As it is a linux system you can use shell scripts and linux is much more powerful in automation tasks than windows. With command redirection via pipes you can build powerful command chains to perform most of your needed tasks. To receive a website you can use wget, to check for a specific line, use grep or sed. There are lots of tutorials out there. On most linux systems mail is built in and properly configured and normally you could even use a small php or bash script to send mails...
For Android there is a great app called Tasker to do automation stuff... It's really worth its costs.
AutoIt only works on windows environments. So you could always emulate a windows environment.
This is by far the worst idea tho.
Here's a link: http://shackspace.de/?p=3859
Is it possible to create some kind of scripting with Genymotion?
I know there is shell commands, but I also need to simulate user touch (using adb input).
The idea is to create some simple test for my app, where the script will execute certain shell commands and adb as well.
Thanks
As Genymotion VMs are considered as a physical device by ADB, you can use MonkeyRunner.
This tool, provided by Google allows you to send touches events among other things.
You can script, using Python many inputs. Look at this gist, coming from this StackOverflow post, it gives good example for a complete gesture.
I am doing some performance testing of the device and want to use the adb and monkey runner to automate andorid UI*. The concern is the background process would affect the actual performance of the device.
Questions are:
Through what mechanism does monkey runner work?
How much the performance* will be affected by the services of adb and monkeyrunner running on the device?
*sending command via adb to run monkey runner and pull the logcat.
*hardware performance: cpu mem power
The MonkeyRunner intro page has a good description of how MonkeyRunner works. Based on my personal experience using MonkeyRunner shouldn't impact your app's performance, however MonkeyRunner itself can sometimes be slow, so I wouldn't ever use MonkeyRunner to measure my app's performance.