- Main Objectives
- Official Documentation Sources
- Additional Tech Info Resources
- Dev Environment
- Nice to have tools
- General guidelines: How to set up dev environment
- Tech Issues and Problem Solving
- Drivers
- Images
- Page Locators
- Page Object Models
i. Calculator:
- Page Object Model
- Base Element Model - Selendroid Test App
- Tests
- Utils
- Creating Mobile Automation Testing Framework for IOS and Android
- Build fast and readable automation using minimal code
- Showcase with effective way to identify app elements
- Page Objects and Element Objects implementation
- Industry-ready test structure
- Ability to pass arguments from CLI (see get_args_from_cli file)
- Build readable test report using Allure Framework
- Test code should avoid violating principles like DRY, YAGNI, SRP and KISS.
- Using built-in apps in order to accomplish all the above
- Appium API Documentation
- Appium Desktop
- Appium Python Client
- Android Debug Bridge (adb)
- Appium Desired Capabilities
- Appium Android Driver
- Automating hybrid apps
- Webdriver API Docs
- Allure Test Report
Additional Tech Info Resources:
- Selenium Documentation
- Full Pytest documentation
- 'Selenium with Python' official documentation webpage
- PyCharm - Manage dependencies using requirements.txt
- Allure Framework
- CREATING A TEST AUTOMATION FRAMEWORK USING APPIUM WITH PYTHON
- How to Setup ADB/Fastboot on Windows
- APPIUM Tutorial for Android & iOS Mobile Apps Testing
- How to print numbers in scientific notation form
- Category Archives: Appium
- Python 3.7.4
- Appium
- Appium-Python-Client 0.47
- Appium Desktop
- PyTest 5.1.1
- Allure Framework 2.12.1
- Win 10 (64 bit)
- PyCharm 2019.2 (Community Edition)
- GitHub Desktop 2.1.2
- GIT 2.22.0.windows.1
- Java SE Development Kit 8 Update 221 (64-bit)
- Node.js v10.6.3
- Appium Server GUI client v1.13.0
- nmp v6.9.0
- Scoop
- Android tablet (real device with Android v7.0)
- Android Studio 3.5
Full list of dependencies see here.
- Fiddler: The free web debugging proxy
- Kite: Code Faster in Python
- Ragnorex: Smart Selector Generator
- Pynsource: Python source code into UML diagrams
- TeamViewer
- AirDroid
- QuickSupport
- App Info, Application Info
- Install Python
- Install PyCharm
- Configure Python virtual environment and activate it
- Install Python prerequisites/packages
- Install Java JDK > configure JAVA_HOME PATH
- Install Android Studio > configure ANDROID_HOME PATH
- Install Node JS
- Install Appium NPM package: open cmd > npm install -g appium
- Install Appium GUI client (optional)
NOTE: for more detailed info please see "Tech Issues and Problem Solving" section
Changing the project interpreter in the PyCharm project settings
1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Project | Project Interpreter.
2. Expand the list of the available interpreters and click the Show All link.
3. Select the target interpreter. When PyCharm stops supporting any of the outdated Python versions, the corresponding project interpreter is marked as unsupported.
4. The Python interpreter name specified in the Name field, becomes visible in the list of available interpreters. Click OK to apply the changes.
For more info please check here
PyCharm - Choosing Your Testing Framework
1. Open the Settings/Preferences dialog, and under the node Tools, click the page Python Integrated Tools.
2. On this page, click the Default Test Runner field.
3. Choose the desired test runner:
For more info please see Enable Pytest for you project
Setting up Python3 virtual environment on Windows machine
- open CMD
- navigate to project directory, for example:
cd C:\Users\superadmin\Desktop\Python\CodinGame
- run following command:
pip install virtualenv
- run following command:
virtualenv venv --python=python
Activate Virtual Environment
In a newly created virtualenv there will be a bin/activate shell script. For Windows systems, activation scripts are provided for CMD.exe and Powershell.
- Open Terminal
- Run: \path\to\env\Scripts\activate
Auto generate requirements.txt
Any application typically has a set of dependencies that are required for that application to work. The requirements file is a way to specify and install specific set of package dependencies at once.
Use pip’s freeze command to generate a requirements.txt file for your project:
pip freeze > requirements.txt
If you save this in requirements.txt, you can follow this guide: PyCharm - Manage dependencies using requirements.txt, or you can:
pip install -r requirements.txt
Source: https://www.idiotinside.com/2015/05/10/python-auto-generate-requirements-txt/
JAVA_HOME PATH
A. In order to configure JAVA_HOME path do the following:
- Go to "Advanced System Settings" > Advanced Tab > Environment Variables
- Go to System Variables section > click on New... button
- Type Variable name: JAVA_HOME
- Enter Variable Value: C:\Program Files\Java\jdk1.8.0_221
- Press OK button
B. Edit environment variable:
- From System variables list select path > Press Edit... button
- Press on New button > type: %JAVA_HOME%\bin
- Press OK button
Environment variables for Android ADB (ANDROID_HOME PATH)
NOTE: Android Studio must be installed first.
A. In order to configure ANDROID_HOME path do the following:
- Go to "Advanced System Settings" > Advanced Tab > Environment Variables
- Go to System Variables section > click on New... button
- Type Variable name: ANDROID_HOME
- Enter Variable Value: C:\Users\username\AppData\Local\Android\Sdk
- Press OK button
B. Edit environment variable:
- From System variables list select path > Press Edit... button
- Press on New button > type: %ANDROID_HOME%\tools
- Press OK button
- Press on New button > type: %ANDROID_HOME%\platform-tools
- Press OK button
C. Test:
- Open CMD > run "adb devices"
- If everifyng is configured properly you will something like this:
Inspect devices with Chrome Developer
1. Open Chrome web browser > new tab
2. Paste following address: chrome:..inspect/#devices
If evryfing connected properly you will see something like this:
Source:
How to restart ADB server
- Open Command promt > run: adb kill-server
- press enter
- run: adb start-server
- press enter
Source: https://stackoverflow.com/questions/29826101/how-to-restart-adb-manually-from-android-studio
Connect to a device over Wi-Fi using Android Debug Bridge (adb)
adb is included in the Android SDK Platform-Tools package. You can download this package with the SDK Manager, which installs it at android_sdk/platform-tools/. Or if you want the standalone Android SDK Platform-Tools package, you can download it here.
Run Appium Tests On Real Android Device over Wifi:
- Connect your device to computer via USB and check if it is connected using ‘adb devices’ which will list you the devices connected to your machine.
- We should make sure that android device and the Laptop are connected to the same Wifi network. In my case wifi is on for laptop and mobile device and not need to purchase any wireless wifi adapter.
- Restart adb and make it work over tcpip by specifying the port value (**adb tcpip 5555). If no port number is specified, Port 5555 is used by default. This step will make your adb daemon to re-start on the specified port.
- We need to get the IP address of the the device. There are two ways to get IP address of your device by using below options:
- Your device -> Settings -> Wifi -> Wifi Settings
- adb shell ip -f inet addr show wlan0
- Your device -> Settings -> Wifi -> Wifi Settings
- Run the below command to connect adb to your device over Wi-Fi using IP address of your device:
- adb connect ip_address:tcpip_port
- adb connect ip_address:tcpip_port
- Confirm that your host computer is connected to the target device:
- adb devices
- adb devices
Source: https://developer.android.com/studio/command-line/adb
Source: https://rajeevkumarweb.wordpress.com/2017/06/03/run-appium-tests-on-real-android-device-over-wifi/
Discover current Activity name with dumpsys
dumpsys is a shell command. You can run it from the command line as follows:
- adb shell
- dumpsys window windows | grep -E 'mCurrentFocus | mFocusedApp'
If you have multiple devices connected, first get their IDs by executing:
- adb devices
Then, replace with the relevant device ID:
- adb -s shell
- dumpsys window windows | grep -E 'mCurrentFocus | mFocusedApp'
You should see something like that:
Source: https://developer.android.com/studio/command-line/dumpsys
Source: https://stackoverflow.com/questions/43178672/dumpsys-window-windows-grep-e-mcurrentfocusmfocusedapp-command-is-not-retu/46545726#46545726
Install the given app from .apk file onto the device
Full Documentation:
** Python code example (Appium):**
self.driver.install_app('/Users/johndoe/path/to/app.apk');
** Code example (adb):**
adb install path/to/your/app.apk('/Users/johndoe/path/to/app.apk');
Common Selenium errors
How to start/stop Appium server programmatically in Python
Using AppiumService Class
The Python client actually comes with a handy module called AppiumService that you can use to programmatically start/stop an Appium server.
To start:
from appium.webdriver.appium_service import AppiumService
appium_service = AppiumService()
self.appium_service.start()
To stop:
self.appium_service.stop()
Using CMD/scripting
To start:
import os
os.system("start /B start cmd.exe @cmd /k appium")
In case you want to change the port(e.g. to 4728) of the appium server (may be when you have multiple servers for multiple devices) you can use following:
import os
os.system("start /B start cmd.exe @cmd /k appium -a 127.0.0.1 -p 4728")
To stop:
os.system("taskkill /F /IM node.exe")
Source:
error: RPC failed; curl 56 Recv failure: Connection was reset
1. Open Git Bash
2. Run: "git config --global http.postBuffer 157286400"
Source: https://stackoverflow.com/questions/36940425/gitlab-push-failed-error
How to fix in case .gitignore is ignored by Git
Even if you haven't tracked the files so far, Git seems to be able to "know" about them even after you add them to .gitignore.
NOTE:
- First commit your current changes, or you will lose them.
- Then run the following commands from the top folder of your Git repository:
git rm -r --cached .
git add .
git commit -m "fixed untracked files"