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

Blogs

Check out the latest blogs from LambdaTest on this topic:

QA&#8217;s and Unit Testing &#8211; Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

LIVE With Automation Testing For OTT Streaming Devices ????

People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.

Why Agile Is Great for Your Business

Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.

Options for Manual Test Case Development &#038; Management

The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

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