How to use assert_exists_and_remove method in Airtest

Best Python code snippet using Airtest

test_android.py

Source:test_android.py Github

copy

Full Screen

...61 self.assertIsInstance(screen, numpy.ndarray)62 self.assertTrue(os.path.exists(filename))63 os.remove(filename)64 def test_snapshot_thread(self):65 def assert_exists_and_remove(filename):66 self.assertTrue(os.path.exists(filename))67 os.remove(filename)68 class ScreenshotThread(Thread):69 def __init__(self, dev, assert_true):70 self.dev = dev71 self._running = True72 self.assert_true = assert_true73 super(ScreenshotThread, self).__init__()74 self.dev.snapshot("screen_thread.jpg")75 assert_exists_and_remove("screen_thread.jpg")76 def terminate(self):77 self._running = False78 def run(self):79 while self._running:80 filename = "screen_thread.jpg"81 self.dev.snapshot(filename)82 assert_exists_and_remove(filename)83 time.sleep(2)84 task = ScreenshotThread(self.android, self.assertTrue)85 task.daemon = True86 task.start()87 for i in range(10):88 self.android.snapshot("screen.jpg")89 assert_exists_and_remove("screen.jpg")90 time.sleep(2)91 task.terminate()92 def test_shell(self):93 self.assertEqual(self.android.shell('echo nimei').strip(), 'nimei')94 def test_keyevent(self):95 self.android.keyevent("BACK")96 def test_wake(self):97 self.android.wake()98 def test_screenon(self):99 self.assertIn(self.android.is_screenon(), (True, False))100 def test_home(self):101 self.android.home()102 def test_text(self):103 self.android.ime_method = IME_METHOD.ADBIME...

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