- JDK 1.8 must be installed ( 1.8.0_251 works fine);
- Nodejs
- Appium GUI
- Android Studio (install sdk package)
Put the following content in .zprofile
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0_251)
export PATH=$PATH:$JAVA_HOME/bin
export ANDROID_HOME=/Users/$(whoami)/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
To verify appium installation, appium-doctor
is used. Installed via npm. See for detailed info:
https://github.com/appium/appium-doctor
Just simply run appium-doctor
in cmd and verify output.
npm install -g appium
Usually appium from npm is installed with separated installed chromedriver. To ge the latest one, run:
npm install -g appium --chromedriver_version="<desired_version_num>"
Or you can simply specify to download chromedirver automatically:
appium --allow-insecure chromedriver_autodownload
All chromedrivers of appium npm will be found:
/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac
After that appium will be available via command line. You can start appium like(in example port is specified):
appium -p 4274
- Via Appium Server Gui - need only click btn "Start Server...";
- Via npm - see section above;
- Programmatically - see
test_appium_starts_itself.py
for details
lsof -P | grep ':<port-num>' | awk '{print $2}' | xargs kill -9
- Enable developer mode.
- Allow debugging on USB connection.
- Connect to computer and select
Transfer files
- Run
adb devices
- you see message like:
List of devices attached
9WV4C19221015777 device
- Start Appium Server
- Run your tests
If you see the following:
List of devices attached
9WV4C19221015777 unauthorized
- Detach device
- Click on phone
Revoke USB debugging authorizations
- Run
adb kill-server
- Run
adb start-server
NB: for tests in Chrome chromedriver is required.
How to open app in chrome devtools:
chrome://inspect/#devices
Then find connected device and click on Inspect
You need to create emulator in Android Studio, ideally with PlayMarket by default
To get emulator name, please run:
emulator -list-avds
After that you need to run the following:
/Users/$(whoami)/Library/Android/sdk/emulator/emulator -avd Pixel_2_API_30 -netdelay none -netspeed full -dns-server 8.8.8.8 -verbose
- if there's no internet connection - create DNS in WI-FI Sections with ip 8.8.8.8 For more info see: https://stackoverflow.com/questions/44535500/internet-stopped-working-on-android-emulator-mac-os
- if emulator is extremely slow, try to reinstall HAXM, see: https://github.com/intel/haxm
- increase memory, try different Boost options (quick/slow)
- run device from cmd, not from Android Studio
- connect real device;
- launch desired apk;
- run
adb shell
; - in shell run
dumpsys window windows | grep -E 'mCurrentFocus'
ordumpsys window windows | grep -E 'mTopActivityComponent'
- From output:
mCurrentFocus=Window{99846e8 u0 com.android.contacts/com.android.contacts.activities.DialtactsActivity}
before slash is package name and after slash is package activity. Add them in desired_caps instead of browser:
desired_caps = dict(
deviceName='Android',
platformName='Android',
appPackage='com.android.contacts',
appActivity='com.android.contacts.activities.DialtactsActivity'
)
Specific capabilities: reset. If noReset
, data after finishing test will be saved.
If fullReset
, then app with data will be deleted completely before session and after test:
{
"fullReset": True,
"noReset": True,
}
To get locators, XPaths, etc.
https://github.com/appium/appium-inspector/
- Start Appium Server
- Connect Device
- Open App for debug
- Open Appium Inspector
- In Appium Inspector add Capabilities, like:
{
"appium:deviceName": "Android",
"platformName": "Android",
"appium:appPackage": "com.android.contacts",
"appium:appActivity": "com.android.contacts.activities.DialtactsActivity"
}
- Add Remote Path value
/wd/hub
- Start the Session
- Open app, which locators are needed.
- Run in terminal:
uiautomatorviewer
- Make snapshot
- If no errors occurred, you see app with locators
- If it doesn't work, verify JDK version
adb -s <device_id> install <path_to_apk_file>
To uninstall package
adb uninstall <package_name>
package_name can be found via dumpsys
command (see above)
adb shell pm list packages
Then run to get package path on device
adb shell pm path <package-name>
Finally, pull apk:
adb pull <path-to-apk-on-device> <path-local-to-save>
Please also verify, that PyCharm detected pytest
as testing framework:
Running tests by word in test function name:
pytest -s -k email
Running tests by word in test function, excluding name:
pytest -s -k "not login"
Running 'marked' tests (e.g. @pytest.mark.functional
):
pytest -s -m "functional"
Running not 'marked' tests (e.g. not @pytest.mark.functional
):
pytest -s -m "not functional"
Running with generation allure
report:
pytest <test_file_name> --alluredir=./allure_reports