Skip to content

Commit

Permalink
Ignore the case where top_activity cannot be obtained
Browse files Browse the repository at this point in the history
忽略无法获取到top_activity的情况

(cherry picked from commit c9c58ab31dc77ee07db14084afd0f1f61aabd28c)
  • Loading branch information
yimelia committed Apr 14, 2022
1 parent 155373e commit d1fc2f9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions poco/drivers/android/uiautomation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from airtest.core.api import connect_device, device as current_device
from airtest.core.android.ime import YosemiteIme
from airtest.core.error import AdbShellError
from airtest.core.error import AdbShellError, AirtestError

from hrpc.client import RpcClient
from hrpc.transport.http import HttpTransport
Expand Down Expand Up @@ -161,7 +161,12 @@ def __init__(self, device=None, using_proxy=True, force_restart=False, use_airte
self.device_ip = self.device.get_ip_address()

# save current top activity (@nullable)
current_top_activity_package = self.device.get_top_activity_name()
try:
current_top_activity_package = self.device.get_top_activity_name()
except AirtestError as e:
# 在一些极端情况下,可能获取不到top activity的信息
print(e)
current_top_activity_package = None
if current_top_activity_package is not None:
current_top_activity_package = current_top_activity_package.split('/')[0]

Expand Down

0 comments on commit d1fc2f9

Please sign in to comment.