python-client icon indicating copy to clipboard operation
python-client copied to clipboard

Wait Activity Appends ".", Error waiting for activity containing package name

Open TiffanyChiangAccenture opened this issue 2 years ago • 3 comments

The problem

Trying to wait for this activity to finish before proceeding with test. Keyword call: Wait Activity com.android.permissioncontroller.permission.ui.GrantPermissionsActivity The activity name is correct, but the python client automatically appends a "." to the activity name if there isn't one.

TimeoutException: Message: Activity .com.android.permissioncontroller.permission.ui.GrantPermissionsActivity never presented, current activity: com.android.permissioncontroller.permission.ui.GrantPermissionsActivity

Code in _android_utils.py

def wait_activity(self, activity, timeout, interval=1):
        """Wait for an activity: block until target activity presents
        or time out.

        Android only.

         - _activity_ - target activity
         - _timeout_ - max wait time, in seconds
         - _interval_ - sleep interval between retries, in seconds
        """

        if not activity.startswith('.'):
            activity = ".%s" % activity

        driver = self._current_application()
        if not driver.wait_activity(activity=activity, timeout=float(timeout), interval=float(interval)):
            raise TimeoutException(msg="Activity %s never presented, current activity: %s" % (activity, self.get_activity()))

Environment

  • Appium version (or git revision) that exhibits the issue: 1.22.0
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: MacOS
  • Node.js version (unless using Appium.app|exe): v12.18.3
  • Mobile platform/version under test: Android v9
  • Real device or emulator/simulator: Android emulator, Pixel 3
  • Appium CLI or Appium.app|exe:
  • Robot Framework: 4.1.2
  • Python: 3.8.5

TiffanyChiangAccenture avatar Mar 15 '22 07:03 TiffanyChiangAccenture

Consider using the most recent version of the library. The implementation of wait_activity is different there: https://github.com/appium/python-client/blob/c97238216e828266819f82538c77a993fdf39cf2/appium/webdriver/extensions/android/activities.py#L72

You could also workaround it by creating a custom wait, which would basically do the same as the method above does (e.g. waiting until the current activity is the same as the expected one)

mykola-mokhnach avatar Mar 15 '22 08:03 mykola-mokhnach

Hey there,

Still facing the very same issue.

higor-haider avatar Mar 15 '24 12:03 higor-haider

Same issue here also

diiogo91 avatar May 22 '24 15:05 diiogo91