Best Python code snippet using ATX
01-navigation.py
Source:01-navigation.py
...47 testcase = 148 status("active")49 MOD.play_stream(Modulation, FEC, SR, Stream, Frequency, Modulator)50 UART.default_settings()51 UART.start_app("")52 RC.push(["key_1", "key_2", "key_3"]) # set of the RC buttons53 sleep(0)54 RC.push("[macros_name]") # RC macros from remote_control.ini file55 GRAB.compare(testcase)"""56############################ TestCase 1 ##########################################57 testcase = 158 status("active")59 UART.default_settings()60 MOD.stop(Modulator)61 MOD.play_stream(Modulation, FEC, SR, Stream, Frequency, Modulator)62 OPER.search()63 UART.start_app("settings")64 GRAB.compare(testcase)65############################ TestCase 2 ##########################################66 testcase = 267 status("active")68 GRAB.compare(testcase)69############################ TestCase 3 ##########################################70 testcase = 371 status("active")72 GRAB.compare(testcase)73############################ TestCase 4 ##########################################74 testcase = 475 status("active")76 GRAB.compare(testcase)77############################ TestCase 5 ##########################################78 testcase = 579 status("active")80 GRAB.compare(testcase)81############################ TestCase 6 ##########################################82 testcase = 683 status("active")84 RC.push(["exit 1 1000", "exit 1 1000", "menu 1 2000"])85 GRAB.compare(testcase)86############################ TestCase 7 ##########################################87 testcase = 788 status("active")89 RC.push(["exit 1 1000", "exit 1 1000", "menu 1 1000", "left 1 1000", "OK 1 1000", "exit 1 1000"])90 GRAB.compare(testcase)91############################ TestCase 8 ##########################################92 testcase = 893 status("manual")94 GRAB.compare(testcase)95############################ TestCase 9 ##########################################96 testcase = 997 status("active")98 UART.start_app("settings")99 RC.push(["menu 1 1000"])100 GRAB.compare(testcase)101############################ TestCase 10 ##########################################102 testcase = 10103 status("active")104 UART.start_app("settings")105 RC.push(["last 1 1000"])106 GRAB.compare(testcase)107############################ TestCase 11 ##########################################108 testcase = 11109 status("active")110 UART.start_app("settings")111 RC.push(["down 1 1000", "exit 1 1000"])112 GRAB.compare(testcase)113############################ TestCase 12 ##########################################114 testcase = 12115 status("active")116 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])117 UART.start_app("settings")118 RC.push(["down 1 1000", "menu 1 1000"])119 GRAB.compare(testcase)120############################ TestCase 13 ##########################################121 testcase = 13122 status("active")123 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])124 UART.start_app("settings")125 RC.push(["down 1 1000", "last 1 1000"])126 GRAB.compare(testcase)127############################ TestCase 14 ##########################################128 testcase = 14129 status("active")130 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])131 UART.start_app("settings")132 RC.push(["up 1 1000"])133 GRAB.compare(testcase)134############################ TestCase 15 ##########################################135 testcase = 15136 status("active")137 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])138 UART.start_app("settings")139 RC.push(["down 1 1000", "up 1 1000"])140 GRAB.compare(testcase)141############################ TestCase 16 ##########################################142 testcase = 16143 status("active")144 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])145 UART.start_app("settings")146 RC.push(["down 1 1000", "down 1 1000", "up 1 1000"])147 GRAB.compare(testcase)148############################ TestCase 17 ##########################################149 testcase = 17150 status("active")151 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])152 UART.start_app("settings")153 RC.push(["down 1 1000"])154 GRAB.compare(testcase)155############################ TestCase 18 ##########################################156 testcase = 18157 status("active")158 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])159 UART.start_app("settings")160 RC.push(["down 1 1000", "down 1 1000"])161 GRAB.compare(testcase)162############################ TestCase 19 ##########################################163 testcase = 19164 status("active")165 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])166 UART.start_app("settings")167 RC.push(["up 1 1000", "down 1 1000"])168 GRAB.compare(testcase)169############################ TestCase 20 ##########################################170 testcase = 20171 status("active")172 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])173 UART.start_app("settings")174 RC.push(["right 10 3000", "right 1 1000"])175 GRAB.compare(testcase)176############################ TestCase 21 ##########################################177 testcase = 21178 status("active")179 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])180 UART.start_app("settings")181 RC.push(["left 10 3000", "right 1 1000"])182 GRAB.compare(testcase)183############################ TestCase 22 ##########################################184 testcase = 22185 status("active")186 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])187 UART.start_app("settings")188 RC.push(["left 10 3000", "left 1 1000"])189 GRAB.compare(testcase)190############################ TestCase 23 ##########################################191 testcase = 23192 status("active")193 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])194 UART.start_app("settings")195 RC.push(["right 10 1000", "left 1 1000"])196 GRAB.compare(testcase)197############################ TestCase 24 ##########################################198 testcase = 24199 status("active")200 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])201 UART.start_app("settings")202 RC.push(["left 10 3000", "right 1 1000", "ChUp 1 1000"])203 GRAB.compare(testcase)204############################ TestCase 25 ##########################################205 testcase = 25206 status("active")207 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])208 UART.start_app("settings")209 RC.push(["left 10 3000", "ChUp 1 1000"])210 GRAB.compare(testcase)211############################ TestCase 26 ##########################################212 testcase = 26213 status("active")214 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])215 UART.start_app("settings")216 RC.push(["left 10 3000", "ChDown 1 1000"])217 GRAB.compare(testcase)218############################ TestCase 27 ##########################################219 testcase = 27220 status("active")221 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])222 UART.start_app("settings")223 RC.push(["right 10 3000", "ChDown 1 1000"])224 GRAB.compare(testcase)225############################ TestCase 28 ##########################################226 testcase = 28227 status("active")228 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])229 UART.start_app("settings")230 RC.push(["left 10 1000", "ok 1 1000"])231 GRAB.compare(testcase)232############################ TestCase 29 ##########################################233 testcase = 29234 status("active")235 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])236 UART.start_app("settings")237 RC.push(["stb 1 1000"])238 GRAB.compare(testcase)239############################ TestCase 30 ##########################################240 testcase = 30241 status("inactive")242 GRAB.compare(testcase)243############################ TestCase 31 ##########################################244 testcase = 31245 status("active")246 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])247 UART.start_app("settings")248 RC.push(["standby 1 10000", "standby 1 10000"])249 GRAB.compare(testcase)250############################ TestCase 32 ##########################################251 testcase = 32252 status("active")253 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])254 UART.start_app("settings")255 RC.push(["VolUp 1 1000"])256 GRAB.compare(testcase)257############################ TestCase 33 ##########################################258 testcase = 33259 status("active")260 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])261 UART.start_app("settings")262 RC.push(["VolDown 1 1000"])263 GRAB.compare(testcase)264############################ TestCase 34 ##########################################265 testcase = 34266 status("active")267 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])268 UART.start_app("settings")269 RC.push(["mute 1 1000"])270 GRAB.compare(testcase)271############################ TestCase 35 ##########################################272 testcase = 35273 status("active")274 UART.default_settings()275 MOD.stop(Modulator)276 MOD.play_stream(Modulation, FEC, SR, Stream, Frequency, Modulator)277 OPER.search()278 RC.push(["menu 1 2000", "left 1 1000", "OK 1 2000", "right 1 1000", "right 1 1000", "exit 1 1000", "OK 1 1000"])279 GRAB.compare(testcase)280############################ TestCase 36 ##########################################281 testcase = 36282 status("active")283 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])284 sleep(60)285 RC.push(["menu 1 2000", "left 1 1000", "OK 1 2000", "right 1 1000", "right 1 1000", "menu 1 1000", "left 1 1000", "OK 1 1000"])286 GRAB.compare(testcase)287############################ TestCase 37 ##########################################288 testcase = 37289 status("active")290 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])291 sleep(60)292 RC.push(["menu 1 2000", "left 1 1000", "OK 1 2000", "right 1 1000", "right 1 1000", "last 1 1000", "menu 1 1000", "left 1 1000", "OK 1 1000"])293 GRAB.compare(testcase)294############################ TestCase 38 ##########################################295 testcase = 38296 status("active")297 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])298 sleep(60)299 RC.push(["menu 1 2000", "left 1 1000", "OK 1 2000", "right 1 1500", "right 1 1500", "exit 1 2000"])300 UART.start_app("settings")301 GRAB.compare(testcase)302############################ TestCase 39 ##########################################303 testcase = 39304 status("active")305 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])306 sleep(60)307 RC.push(["menu 1 2000", "left 1 1000", "OK 1 2000", "right 1 1000", "right 1 1000", "menu 1 2000"])308 UART.start_app("settings")309 GRAB.compare(testcase)310############################ TestCase 40 ##########################################311 testcase = 40312 status("active")313 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])314 sleep(60)315 RC.push(["menu 1 2000", "left 1 1000", "OK 1 2000", "right 1 1000", "right 1 1000", "last 1 1000"])316 UART.start_app("settings")317 GRAB.compare(testcase)318############################ TestCase 41 ##########################################319 testcase = 41320 status("active")321 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])322 sleep(60)323 UART.start_app("settings")324 RC.push(["right 1 1000", "right 1 1000", "exit 1 1000", "exit 1 1000"])325 RC.push(["menu 1 2000", "left 1 1000", "OK 1 2000"])326 GRAB.compare(testcase)327############################ TestCase 42 ##########################################328 testcase = 42329 status("active")330 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])331 sleep(60)332 UART.start_app("settings")333 RC.push(["right 1 1000", "right 1 1000", "menu 1 1000"])334 RC.push(["left 1 1000", "OK 1 2000"])335 GRAB.compare(testcase)336############################ TestCase 43 ##########################################337 testcase = 43338 status("active")339 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])340 sleep(60)341 UART.start_app("settings")342 RC.push(["right 1 1000", "right 1 1000", "last 1 1000"])343 RC.push(["menu 1 1000", "left 1 1000", "OK 1 2000"])344 GRAB.compare(testcase)345############################ TestCase 44 ##########################################346 testcase = 44347 status("active")348 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])349 sleep(60)350 UART.start_app("settings")351 RC.push(["right 1 1000", "right 1 1000", "exit 1 1000"])352 UART.start_app("settings")353 GRAB.compare(testcase)354############################ TestCase 45 ##########################################355 testcase = 45356 status("active")357 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])358 sleep(60)359 UART.start_app("settings")360 RC.push(["right 1 1000", "right 1 1000", "menu 1 1000"])361 UART.start_app("settings")362 GRAB.compare(testcase)363############################ TestCase 46 ##########################################364 testcase = 46365 status("active")366 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])367 sleep(60)368 UART.start_app("settings")369 RC.push(["right 1 1000", "right 1 1000", "last 1 1000"])370 UART.start_app("settings")371 GRAB.compare(testcase)372############################ TestCase 47 ##########################################373 testcase = 47374 status("active")375 RC.push(["exit 1 1000", "exit 1 1000", "exit 1 1000"])376 sleep(60)377 UART.start_app("settings")378 RC.push(["right 1 1000", "right 1 6000", "standby 1 15000", "standby 1 15000"])379 UART.start_app("settings")380 GRAB.compare(testcase)381############################ TestCase 48 ##########################################382 testcase = 48383 status("manual")384 GRAB.compare(testcase)385###################################################################################386 status("active")387 MOD.stop(Modulator)...
checkin.py
Source:checkin.py
...175 # 3. å¯å¨ç¨åº176 phone.tap(pid, COLUMNS[2] * w / WIDTH, ROWS[2] * h / HEIGHT, gap)177# 49-72178def toutiao(pid, gap=10):179 phone.start_app(pid, activities[180 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)181def kuaishou(pid, gap=10):182 phone.start_app(pid, activities[183 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)184def douyin(pid, gap=10):185 phone.start_app(pid, activities[186 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)187def huoshan(pid, gap=10):188 phone.start_app(pid, activities[189 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)190def qutoutiao(pid, gap=15):191 phone.start_app(pid, activities[192 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)193def baidu(pid, gap=15):194 phone.start_app(pid, activities[195 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)196def weishi(pid, gap=15):197 phone.start_app(pid, activities[198 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)199def ximalaya(pid, gap=15):200 phone.start_app(pid, activities[201 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)202def wuba(pid, gap=10):203 phone.start_app(pid, activities[204 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)205def taobao(pid, gap=10):206 phone.start_app(pid, activities[207 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)208def shuabao(pid, gap=10):209 phone.start_app(pid, activities[210 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)211def qqyuedu(pid, gap=10):212 phone.start_app(pid, activities[213 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)214def chejia(pid, gap=10):215 phone.start_app(pid, activities[216 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)217def uc(pid, gap=15):218 phone.start_app(pid, activities[219 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)220def kuaikandian(pid, gap=10):221 phone.start_app(pid, activities[222 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)223def hongshi(pid, gap=15):224 phone.start_app(pid, activities[225 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)226def doudou(pid, gap=15):227 phone.start_app(pid, activities[228 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)229def qimao(pid, gap=15):230 phone.start_app(pid, activities[231 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)232def douhuo(pid, gap=10):233 phone.start_app(pid, activities[234 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)235def moji(pid, gap=10):236 phone.start_app(pid, activities[237 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)238def tangdou(pid, gap=15):239 phone.start_app(pid, activities[240 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)241def yangcong(pid, gap=15):242 phone.start_app(pid, activities[243 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)244# 73-96245def qqliulan(pid, gap=15):246 phone.start_app(pid, activities[247 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)248def lingshenghui(pid, gap=15):249 phone.start_app(pid, activities[250 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)251def zhuanshi(pid, gap=15):252 phone.start_app(pid, activities[253 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)254def tengzhi(pid, gap=15):255 phone.start_app(pid, activities[256 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)257def zhaoshang(pid, gap=15):258 phone.start_app(pid, activities[259 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)260def gudong(pid, gap=15):261 phone.start_app(pid, activities[262 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)263def xiongmao(pid, gap=15):264 phone.start_app(pid, activities[265 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)266def buduoduo(pid, gap=15):267 phone.start_app(pid, activities[268 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)269def duokan(pid, gap=15):270 phone.start_app(pid, activities[271 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)272def shandian(pid, gap=15):273 phone.start_app(pid, activities[274 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)275def taozhi(pid, gap=15):276 phone.start_app(pid, activities[277 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)278def cainiao(pid, gap=15):279 phone.start_app(pid, activities[280 inspect.getframeinfo(inspect.currentframe()).function.__str__()], gap)281# last282def weixin(pid, gap=10):283 phone.start_app(pid, activities[...
test_hnp.py
Source:test_hnp.py
2import json3from test.get_app import init_test_app4BASE_DIR = pathlib.Path(__file__).parent.parent5config_path = '/config/config.toml'6def start_app():7 return init_test_app(f'{BASE_DIR}{config_path}')8class TestHackerNewsParser:9 async def test_get_posts(self, aiohttp_client):10 app = start_app()11 client = await aiohttp_client(app)12 response = await client.get('/v1/posts')13 assert response.status == 20014 text = await response.text()15 print(text)16 body = response.__dict__17 data = json.loads(body.get("_body"))18 assert isinstance(data, list)19 assert len(data) == 520 print(f'---------------------------------')21 async def test_get_10_posts(self, aiohttp_client):22 app = start_app()23 client = await aiohttp_client(app)24 response = await client.get('/v1/posts?limit=10')25 assert response.status == 20026 text = await response.text()27 print(text)28 body = response.__dict__29 data = json.loads(body.get("_body"))30 assert isinstance(data, list)31 assert len(data) == 1032 print(f'---------------------------------')33 async def test_get_offset_posts(self, aiohttp_client):34 app = start_app()35 client = await aiohttp_client(app)36 response = await client.get('/v1/posts?limit=7&offset=1')37 assert response.status == 20038 text = await response.text()39 print(text)40 body = response.__dict__41 data = json.loads(body.get("_body"))42 assert isinstance(data, list)43 assert len(data) == 744 print(f'---------------------------------')45 async def test_get_asc_id_posts(self, aiohttp_client):46 app = start_app()47 client = await aiohttp_client(app)48 response = await client.get('/v1/posts?sort=asc')49 assert response.status == 20050 text = await response.text()51 print(text)52 body = response.__dict__53 data = json.loads(body.get("_body"))54 assert isinstance(data, list)55 assert len(data) == 556 print(f'---------------------------------')57 async def test_get_desc_id_posts(self, aiohttp_client):58 app = start_app()59 client = await aiohttp_client(app)60 response = await client.get('/v1/posts?sort=desc')61 assert response.status == 20062 text = await response.text()63 print(text)64 body = response.__dict__65 data = json.loads(body.get("_body"))66 assert isinstance(data, list)67 assert len(data) == 568 print(f'---------------------------------')69 async def test_get_title_desc_posts(self, aiohttp_client):70 app = start_app()71 client = await aiohttp_client(app)72 response = await client.get('/v1/posts?order=title')73 assert response.status == 20074 text = await response.text()75 print(text)76 body = response.__dict__77 data = json.loads(body.get("_body"))78 assert isinstance(data, list)79 assert len(data) == 580 print(f'---------------------------------')81 async def test_get_title_asc_posts(self, aiohttp_client):82 app = start_app()83 client = await aiohttp_client(app)84 response = await client.get('/v1/posts?order=title&sort=asc')85 assert response.status == 20086 text = await response.text()87 print(text)88 body = response.__dict__89 data = json.loads(body.get("_body"))90 assert isinstance(data, list)91 assert len(data) == 592 print(f'---------------------------------')93 async def test_get_combine_posts(self, aiohttp_client):94 app = start_app()95 client = await aiohttp_client(app)96 response = await client.get(97 '/v1/posts?order=title&sort=asc&limit=10&offset=2')98 assert response.status == 20099 text = await response.text()100 print(text)101 body = response.__dict__102 data = json.loads(body.get("_body"))103 assert isinstance(data, list)104 assert len(data) == 10...
android_permissions.py
Source:android_permissions.py
...17#18# def on_start(self):19# self.dont_gc = AndroidPermissions(self.start_app)20#21# def start_app(self):22# self.dont_gc = None23#24###########################################################################25#26# Android Behavior:27#28# If the user selects "Don't Allow", the ONLY way to enable29# the disallowed permission is with App Settings.30# This class give the user an additional chance if "Don't Allow" is31# selected once.32#33###########################################################################34class AndroidPermissions:35 def __init__(self, start_app = None):36 self.permission_dialog_count = 037 self.start_app = start_app38 if platform == 'android':39 #################################################40 # Customize run time permissions for the app here41 #################################################42 self.permissions = [Permission.CAMERA]43 ################################################# 44 self.permission_status([],[])45 elif self.start_app:46 self.start_app()47 def permission_status(self, permissions, grants):48 granted = True49 for p in self.permissions:50 granted = granted and check_permission(p)51 if granted:52 if self.start_app:53 self.start_app()54 elif self.permission_dialog_count < 2:55 Clock.schedule_once(self.permission_dialog) 56 else:57 self.no_permission_view()58 59 def permission_dialog(self, dt):60 self.permission_dialog_count += 161 request_permissions(self.permissions, self.permission_status)62 @mainthread63 def no_permission_view(self):64 view = ModalView()65 view.add_widget(Button(text='Permission NOT granted.\n\n' +\66 'Tap to quit app.\n\n\n' +\67 'If you selected "Don\'t Allow",\n' +\...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!