Dec 13, 2016 - This post looks at using Desired Capabilities in Appium and how to gather desired capabilities and create Appium Test Script In Eclipse.
This will be the 2nd blog of our Items You Should Know About Appium blog series, and this period we'll continue with some basic points around using Python with Appium. For starters, we'll consider a look at simple illustrations of how to use Python and compose a few outlines of code to get your programs automatically published to Bitbar Testing and performed on actual Android and/or iOS devices.
If you adopted through the very first blog site where we walked through the simple setup, installation of Python, and some various other factors, you can continue with the simple code example. If you put on't possess Python properly set up or you need to verify whether everything is certainly prepared to move forwards,obtain our free Appium beginner's information to confirm your set up and find out how to established up additional dialects.
Python is definitely a useful script vocabulary option for those who would like to obtain down to company quick and easy. The syntax is actually easy to understand and implement and there isn't usually a large cluster of different files required. Generally when I wish to test some Appium function, which I haven't handled just before, I change to python to examine it óut.
Créating and Running an Upload Script
Before the actual testing can take place, you need to upload your cellular software to the cloud. The app can become in form of APK ór IPA - and tó obtain you an efficient start, we'll develop a short upload software here. The upload screenplay example is usually also accessible at Github. For IPA files, please furthermore make certain they're properly built for make use of in Bitbar Assessment.
Configuré your
usérname
,password
andmyfile
characteristics with your Bitbar Testing login qualifications, and document route for your program (this can be APK or lPA).Now, you can operate the upload screenplay using the subsequent command:
As an result you'll get something Iike this:
Fróm this reaction message, you need to store the application's ID and file title in Bitbar Tests. The above instance is usually
'99becd25-3183-4c7f-998e-84ey307de7a5/test.apk'
.Creating and Working a Test Software
Common Configurations
Now there are some common configurations that you need to established in all scripts regardless of the app type that you are usually screening. Each testdroid.py file needs to end up being up to date with the suitable values. For this illustration, here are all the values that you need to modify:
screenshotDir- whére should screenshots become kept on your local drive
bundleId - this is usually your program's unique title. For instance, it can be utilized in your Python check screenplay as follows:
téstdroidusername
- the e-mail that you use to sign up for Bitbar Examiningtéstdroidpassword
- your security passwordtestdroidproject
- the title of the project you need to make use of. Each task must have got a unique title, which can furthermore be customized later. The task will end up being automatically produced, if it doesn't already can be found in the fog up.téstdroidtestrun
- the name of this check run. Test run brands can also be altered later and they put on't have got to become exclusive.téstdroidapp
- the area of the app you uploaded to the cloud. Eg. if you published your app making use of the upload.py script this would appear like '99becd25-3183-4c7f-998e-84ey307de7a5/test.apk'. An substitute way to this can be posting the app through the fog up portal and then make use of the worth ‘most recent' rather of an id route.Local Android Particular Configurations
You can make use of our template document as an example: testdroidandroid.py fróm Github.
ln order to configure this software for your testing needs and for your own app, you can edit two additional capabilities as comes after:
appPackage- Jáva deal of the Android app you wish to operateappActivity
- Action name for the Android activity you wish to release from your package deal. Usually this is certainly the main action.Local iOS Particular Settings
You can make use of our template file as an illustration: testdroidios.py fróm Github.
Notice! In inclusion to various other constructions and desired capabilities, Appium requires a bunch identity to end up being incorporated in the test software:
An Example Template for Desired Capabilities and Set up
You can find all the tempIate scripts from óur Github repository. There are illustrations for Google android, iOS, Safari, Chrome, and furthermore Android cross types for cross types apps.
Ok, allow's appear at a concrete Python check script instance then and what goes in the program code:
Imported libraries, bundles and other your local library/dependencies:
Next, allow's make a class with the gadget, login and configuration particular desired capabilities. For instance:
To select a device from Bitbar Assessment, you can search for the desired design from our Device Groups web page. Once you discovered the model you need to use, simply copy the full name of the gadget to testdroiddevice adjustable.
You can furthermore use the DeviceFinder class to immediately find an available freemium device for your test run on Bitbar Tests:
After that, to choose right automation backend for the server, you need to fetch the API level of the device which will become used for a check work:
Lastly, let's take a look at the desired capabilities configuration with your Python software.
One more thing! Allow's initiate and fixed up WebDriver:
Suggestions!
You can set Environment Variables to shop all the désired capabilities that received't become changing usually. This reasoning is currently included in the small sample scripts so all you need to do is established the variables! For example, to arranged up your Bitbar username, merely utilize [email protected] to your environment and the software will then find it with the operating-system.environ.get functionality. If the variable doesn't exist, the script will shift on to the following declaration after the ‘ór' kéyword.
Playing around with the Google android appPackage and appActivity ideals may end up being useful when producing tests to automate particular activity screens of your app. There is definitely furthermore a command word to launch another app while one is certainly already becoming tested! This features is obtainable for Google android only even though.
Happy Appium Tests (and weekend)! We'll be continuing with a fresh topic on Mon!