How to use app_current method in Airtest

Best Python code snippet using Airtest

tool3.py

Source:tool3.py Github

copy

Full Screen

...37 38 def lookrunning_apps0(self, event):39 d = u2.connect()40 str000 = ""41 str000 += str(d.app_current()["package"])42 str000 += "\n"43 # print(dev_phone0.app_info(dev_phone0.app_current()["package"]))# print(dev_phone0.app_info(dev_phone0.app_current()["package"]))44 # print(d.app_info(d.app_current()["package"]))45 sss = d.app_info(d.app_current()["package"])46 str000 += f'{sss}'47 wx.MessageBox(f"{str000}", "Message" ,wx.OK | wx.ICON_INFORMATION) 48 event.Skip()49 return super().lookrunning_apps0(event)50 def close_apps0(self, event):51 d = u2.connect()52 d.app_stop_all()53 event.Skip()54 return super().close_apps0(event)55 56 def install_apps0(self, event):57 d = u2.connect()58 app_to_install = self.m_filePicker1.GetPath()59 print(app_to_install)60 d.app_install(app_to_install)61 event.Skip()62 return super().install_apps0(event)63 64 def delete_apps0(self, event):65 d = u2.connect()66 app_to_uninstall = self.m_textCtrl1.GetValue()67 print(app_to_uninstall)68 d.app_uninstall(app_to_uninstall)69 event.Skip()70 return super().delete_apps0(event)71 72def apps_main_managing():73 app = wx.App(False)74 frame = CalcFrame0001(None)75 frame.Show(True)76 # start the applications77 app.MainLoop()78# if __name__ == "__main__":79 # apps_main_managing()80# dev_phone0 = u2.connect()81# print(dev_phone0.app_current())82# print(dev_phone0.app_list())83# # wx.MessageBox(f"Successfully.", "Message") 84# 85# res0 = []86# for t in dev_phone0.app_list():87# res0.append(t)88# 89# n = 190# str00 = ""91# for i in res0:92# if n < 10:93# str00 += f"00{n}.{i};\n"94# elif n < 100:95# str00 += f"0{n}.{i};\n"96# else:97# str00 += f"{n}.{i};\n"98# n += 199# str00 = str00[:-2] + "."100# print(str00)101# 102# ...

Full Screen

Full Screen

app_utils.py

Source:app_utils.py Github

copy

Full Screen

...4import uiautomator2 as u25def launch_app(device: u2.Device, package_name: str, activity: str):6 device.app_start(package_name=package_name, activity=activity)7def top_app(device: u2.Device) -> str:8 return device.app_current()['package']9def top_activity(device: u2.Device) -> str:10 return device.app_current()['package'] + device.app_current()['activity']11def activity_window(device: u2.Device, activity: str) -> list:12 wins = device.shell("dumpsys window " + activity + " | grep \"Window #\"")13 return wins.output.strip().split('\n')14def input_shown(device: u2.Device) -> bool:15 input_info = device.shell('dumpsys input_method | grep mInputShown').output.strip()16 return re.compile(r"mInputShown=(\S+)").findall(input_info)[0] == 'true'17def deal_with_permission() -> int:18 return 019def deal_with_common_dialog() -> int:20 return 021def deal_with_upgrade_dialog() -> int:22 return 023if __name__ == '__main__':24 current_device = u2.connect()...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...3d.app_start('com.test.helloworld', '.MainActivity')4# 主页面5t = d(resourceId="com.test.helloworld:id/textView").get_text()6print(t)7print(d.app_current())8print()9# 页面B10d(text="BUTTON1").click()11text = d(textStartsWith="This").get_text()12print(text)13print(d.app_current())14d.press("back")15print()16# 页面C17d(text="BUTTON2").click()18d(resourceId="com.test.helloworld:id/etActivityc").send_keys("thishsishishfh")19d(resourceId="com.test.helloworld:id/buttonc1").click()20t = d(resourceId="com.test.helloworld:id/textView").get_text()21print(t)22print("thishsishishfh" == str(t).split(":")[1])...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful