Best Python code snippet using uiautomator
test_dialog.py
Source:test_dialog.py
1#!/usr/bin/env python2import desktop.dialog3def test_open(obj, desktop=None):4 try:5 return obj.open(desktop)6 except OSError:7 return None8def test_question():9 obj = desktop.dialog.Question("Are you sure?", 40, 5)10 print test_open(obj)11 print test_open(obj, "KDE")12 print test_open(obj, "GNOME")13 print test_open(obj, "X11")14def test_message():15 obj = desktop.dialog.Message("Hello world!", 40, 5)16 print test_open(obj)17 print test_open(obj, "KDE")18 print test_open(obj, "GNOME")19 print test_open(obj, "X11")20def test_warning():21 obj = desktop.dialog.Warning("Beware of the penguin!", 40, 5)22 print test_open(obj)23 print test_open(obj, "KDE")24 print test_open(obj, "GNOME")25 print test_open(obj, "X11")26def test_error():27 obj = desktop.dialog.Error("Penguin invasion complete!", 40, 5)28 print test_open(obj)29 print test_open(obj, "KDE")30 print test_open(obj, "GNOME")31 print test_open(obj, "X11")32def test_menu():33 obj = desktop.dialog.Menu("Choose an animal", ["Animal"], width=40, height=15, list_height=5)34 obj.add("a", "Antelope")35 obj.add("b", "Badger")36 obj.add("c", "Cow")37 obj.add("d", "Dog")38 obj.add("e", "Elephant")39 obj.add("f", "Fox")40 obj.add("g", "Giraffe")41 obj.add("h", "Horse")42 obj.add("i", "Iguana")43 print repr(test_open(obj))44 print repr(test_open(obj, "KDE"))45 print repr(test_open(obj, "GNOME"))46 print repr(test_open(obj, "X11"))47def test_checklist():48 obj = desktop.dialog.CheckList("Choose some animals", ["Animal"], width=40, height=15, list_height=5)49 obj.add("a", "Antelope")50 obj.add("b", "Badger", 1)51 obj.add("c", "Cow", 0)52 obj.add("d", "Dog")53 obj.add("e", "Elephant")54 obj.add("f", "Fox", 1)55 obj.add("g", "Giraffe")56 obj.add("h", "Horse")57 obj.add("i", "Iguana")58 print repr(test_open(obj))59 print repr(test_open(obj, "KDE"))60 print repr(test_open(obj, "GNOME"))61 print repr(test_open(obj, "X11"))62def test_radiolist():63 obj = desktop.dialog.RadioList("Choose one animal", ["Animal"], width=40, height=15, list_height=5)64 obj.add("a", "Antelope")65 obj.add("b", "Badger", 1)66 obj.add("c", "Cow", 0)67 obj.add("d", "Dog")68 obj.add("e", "Elephant")69 obj.add("f", "Fox", 1)70 obj.add("g", "Giraffe")71 obj.add("h", "Horse")72 obj.add("i", "Iguana")73 print repr(test_open(obj))74 print repr(test_open(obj, "KDE"))75 print repr(test_open(obj, "GNOME"))76 print repr(test_open(obj, "X11"))77def test_pulldown():78 obj = desktop.dialog.Pulldown("Choose an animal", ["Animal"], width=40, height=15, list_height=5)79 obj.add("Antelope")80 obj.add("Badger")81 obj.add("Cow")82 obj.add("Dog")83 obj.add("Elephant")84 obj.add("Fox")85 obj.add("Giraffe")86 obj.add("Horse")87 obj.add("Iguana")88 print repr(test_open(obj))89 print repr(test_open(obj, "KDE"))90 print repr(test_open(obj, "GNOME"))91 print repr(test_open(obj, "X11"))92def test_input():93 obj = desktop.dialog.Input("Enter your name!", "Monty", 40, 5)94 print repr(test_open(obj))95 print repr(test_open(obj, "KDE"))96 print repr(test_open(obj, "GNOME"))97 print repr(test_open(obj, "X11"))98def test_password():99 obj = desktop.dialog.Password("Enter your password!", "Python", 40, 5)100 print repr(test_open(obj))101 print repr(test_open(obj, "KDE"))102 print repr(test_open(obj, "GNOME"))103 print repr(test_open(obj, "X11"))104def test_textfile():105 obj = desktop.dialog.TextFile("README.txt", "Showing file...", 80, 25)106 print repr(test_open(obj))107 print repr(test_open(obj, "KDE"))108 print repr(test_open(obj, "GNOME"))109 print repr(test_open(obj, "X11"))110test_question()111test_message()112test_warning()113test_error()114test_menu()115test_checklist()116test_radiolist()117test_pulldown()118test_input()119test_password()120test_textfile()...
ss_systems_reverse.py
Source:ss_systems_reverse.py
1import fem3d_2ss2import numpy as np3fem2ss = fem3d_2ss.Fem3d_fenics('test_open/')4p1=np.load('test_open/p1.npy')5p2=np.load('test_open/p2.npy')6# p1r=np.load('test_open/p1r.npy')7vars={}8vars['A'] = fem2ss.A9vars['B'] = fem2ss.B10vars['Bv'] = fem2ss.Bv11vars['C1'] = fem2ss.get_C(p1)12vars['C2'] = fem2ss.get_C(p2, 2)13# vars['C1r'] = fem2ss.get_C(p1r)14# vars['Ar'] = np.load('test_open/AA3dr.npy')15# vars['Br'] = np.load('test_open/BB3dr.npy')16# vars['Bvr'] = np.load('test_open/BB3dvr.npy')17vars['od'] = np.load('test_open/open_loop_data.npy')18vars['T0'] = np.load('test_open/T03d.npy')19vars['T0r'] = np.load('test_open/T03dr.npy')20vars['AAA'] = np.load('test_open/AAA.npy')21vars['BB'] = np.load('test_open/BB.npy')22vars['BBv'] = np.load('test_open/BBv.npy')23vars['TT0'] = np.load('test_open/TT0.npy')24vars['TT0r'] = np.load('test_open/TT0r.npy')25import scipy.io26# scipy.io.savemat('ss_vars_reverse.mat', vars)27scipy.io.savemat('ss_plants2.mat', vars)28vars={}29import numpy as np30vars['cd'] = np.load('ctrl_qft_manu4.npy')31import scipy.io32scipy.io.savemat('ctrl_qft_manu5.mat', vars)33# vars={}34# vars['step10'] = np.load('test_open/ctrl_steps_data.npy')35# vars['step100'] = np.load('test_open/ctrl_steps_data100.npy')36# import scipy.io...
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!!