appium: Android emulator does not quit automatically
The problem
When running Selenium tests on an Android virtual device, the device does not power off after the test ends, and the emulator does not quit.
Environment
- Appium version (or git revision) that exhibits the issue: 1.6.3
- Last Appium version that did not exhibit the issue (if applicable):
- Desktop OS/version used to run Appium: macOS 10.12.2
- Node.js version (unless using Appium.app|exe): 7.1.0
- Mobile platform/version under test: Android 5.1.1, 6.0, 7.1.1
- Real device or emulator/simulator: Emulator
- Appium CLI or Appium.app|exe: Appium CLI
Details
I have a basic Python script that runs a simple test with Selenium and Appium in a web browser.
The test runs all right but afterwards, the emulator itself never quits. I expected that it would behave like the iOS simulator.
Since the emulator does not quit automatically, I can also not conveniently run tests on another virtual device on the same host machine (attempting to do so can lead Appium to crash).
Link to Appium logs
https://gist.github.com/SteffenL/2f01cad53d43bf5ec34a54e00c386aaf
Code To Reproduce Issue [ Good To Have ]
Sample code: sample-code/examples/python/android_simple.py
A simpler example:
from selenium import webdriver
cap = {"browserName": "Browser", "platformName": "Android", "deviceName": "Android Emulator", "platformVersion": "5.1.1", "automationName": "Appium", "avd": "Nexus_5_5.1.1"}
driver = webdriver.Remote("http://localhost:4723/wd/hub", cap)
driver.get("http://www.seleniumhq.org/")
driver.quit()
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 18 (4 by maintainers)
+1 how can we influence to increase the priority of this ticket? đ
@mykola-mokhnach - this UIA2 feature works to close the emulator but i think there is a little bit of a chicken-and-egg problem. The issue is that if you call driver.executeScript(âmobile: execEmuConsoleCommandâ, âkillâ, âdevice_udidâ) before driver.quit(), driver.quit() will fail because emulator is gone. And you cant execute the kill command after driver.quit() because session will be null. IMO, closing the emulator needs to be made part of the driver.quit() call routine. Agree with @jlipps previous suggestion that maybe the kill command in driver.quit() can be conditional on the avd capability. Does this sound reasonable?
I ended up just adding a post-build step command-line to my Jenkins job that kicks off the Android automation at scheduled times throughout the dayâŚ
adb emu kill
This seems to have cleared up a lot of my previous issues of the emulator getting âflakeyâ.
Iâm open to adding a capability that will kill the emu in between tests if Appium started it. Adding as an enhancement