检查设备上当前打开的应用程序

Check which app is currently open on device

我可以通过 appium 启动应用程序并使用该驱动程序通过 Python 进行 UI 交互。 但我正在尝试通过 python 脚本启动应用程序。例如脸书应用程序。 我可以确定当前打开的是哪个应用程序吗? 或者我可以使用 appium 在当前打开的应用程序上进行 UI 交互吗?

我想知道哪个应用程序当前正在打开,或者哪个 url 在浏览器的 playstore 中启动? appium 可以处理这个还是我需要使用其他东西? 或者我可以使用 adb 提取此信息吗?

你可以试试driver.current_activity方法:

来自手册:

Retrieving the current running activity The property method driver.current_activity returns the name of the current activity running on the device.

activity = driver.current_activity
assertEquals('.ApiDemos', activity)