How to use set_focus method in toolium

Best Python code snippet using toolium_python

urwidwrapper.py

Source:urwidwrapper.py Github

copy

Full Screen

...77 self.tab_prev(self.focus_position)78 else:79 return self.__super.keypress(size, key)80 def tab_next(self, pos):81 self.set_focus(pos + 1)82 maxlen = (len(self.contents) - 1)83 while pos < maxlen:84 if self.contents[pos][0].selectable():85 return86 else:87 pos += 188 if pos >= maxlen:89 pos = 090 self.set_focus(pos)91 def tab_prev(self, pos):92 self.set_focus(pos - 1)93 while pos > 0:94 if self.contents[pos][0].selectable():95 return96 else:97 pos -= 198 if pos == 0:99 pos = (len(self.contents) - 1)100 self.set_focus(pos)101 def first_selectable(self):102 '''returns index of first selectable widget in contents.'''103 for pos, item in enumerate(self.contents):104 if item[0].selectable():105 return pos106 return (len(self.contents) - 1)107class TabbedColumns(urwid.Columns):108 def __init__(self, widget_list, dividechars=0, focus_column=None,109 min_width=1, box_columns=None):110 urwid.Columns.__init__(self, widget_list,111 dividechars=dividechars,112 focus_column=focus_column,113 min_width=min_width,114 box_columns=box_columns)115 def keypress(self, size, key):116 if key == 'tab' and self.focus_position < (len(self.contents) - 1)\117 and self.widget_list[self.focus_position + 1].selectable():118 self.tab_next(self.focus_position)119 elif key == 'shift tab' and self.focus_position > 0 \120 and self.widget_list[self.focus_position - 1].selectable():121 self.tab_prev(self.focus_position)122 else:123 return self.__super.keypress(size, key)124 def tab_next(self, pos):125 self.set_focus(pos + 1)126 maxlen = (len(self.contents) - 1)127 while pos < maxlen:128 if self.widget_list[pos].selectable():129 return130 else:131 pos += 1132 if pos >= maxlen:133 pos = 0134 self.set_focus(pos)135 def tab_prev(self, pos):136 self.set_focus(pos - 1)137 while pos > 0:138 if self.widget_list[pos].selectable():139 return140 else:141 pos -= 1142 if pos == 0:143 pos = (len(self.widget_list) - 1)144 self.set_focus(pos)145 def first_selectable(self):146 '''returns index of first selectable widget in widget_list.'''147 for pos, item in enumerate(self.widget_list):148 if item.selectable():149 return pos150 return (len(self.widget_list) - 1)151class TextWithTip(urwid.Edit):152 def __init__(self, label, default_value=None, tooltip=None, toolbar=None,153 mask=None):154 urwid.Edit.__init__(self, caption=label, edit_text=default_value,155 mask=mask)156 self.tip = tooltip157 self.toolbar = toolbar158 def render(self, size, focus=False):159 if focus:160 self.toolbar.set_text(self.tip)161 canv = super(TextWithTip, self).render(size, focus)162 return canv163class TabbedListWalker(urwid.ListWalker):164 def __init__(self, lst):165 self.lst = lst166 self.focus = 0167 def _modified(self):168 return urwid.ListWalker._modified(self)169 def tab_next(self):170 item, pos = self.get_next(self.focus)171 while pos is not None:172 if item.selectable():173 break174 else:175 item, pos = self.get_next(pos)176 if pos is None:177 pos = 0178 self.focus = pos179 self._modified()180 try:181 #Reset focus to first selectable widget in item182 if hasattr(item, 'original_widget'):183 item.original_widget.set_focus(184 item.original_widget.first_selectable())185 else:186 item.set_focus(item.first_selectable())187 except Exception:188 #Ignore failure. Case only applies to TabbedColumns and189 #TabbedGridFlow. Other items should fail silently.190 pass191 def tab_prev(self):192 item, pos = self.get_prev(self.focus)193 while pos is not None:194 if item.selectable():195 break196 else:197 item, pos = self.get_prev(pos)198 if pos is None:199 pos = (len(self.lst) - 1)200 self.focus = pos201 self._modified()202 try:203 if hasattr(item, 'original_widget'):204 item.original_widget.set_focus(205 len(item.original_widget.contents) - 1)206 else:207 item.set_focus(len(item.contents) - 1)208 except Exception:209 #Ignore failure. Case only applies to TabbedColumns and210 #TabbedGridFlow. Other items should fail silently.211 pass212 def get_focus(self):213 if self.lst:214 return self.lst[self.focus], self.focus215 else:216 return None, None217 def set_focus(self, focus):218 self.focus = focus219 def get_next(self, pos):220 if (pos + 1) >= len(self.lst):221 return None, None222 return self.lst[pos + 1], pos + 1223 def get_prev(self, pos):224 if (pos - 1) < 0:225 return None, None...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...52 app['Abrir empresa']['Edit7'].type_keys(data['password'])53 app['Abrir empresa']['Button3'].click()5455if main.exists(timeout=5) and not lg.exists(timeout=5):56 main.set_focus()57else:58 for i in range(15):59 try:60 app.set_focus()61 keyboard.send_keys('%x')62 keyboard.send_keys('%a')6364 if lg.exists(timeout=5):65 app['Abrir empresa']['Edit5'].type_keys(data['user_name'])66 app['Abrir empresa']['Edit7'].type_keys(data['password'])67 app['Abrir empresa']['Button3'].click()68 69 main.set_focus()70 break7172 except Exception as e:73 pass74sleep(10)75keyboard.send_keys('%e')76sleep(10)77keyboard.send_keys('^%e')7879main2=main.child_window(title_re=".*Administrador de Estadísticas.*")8081if main2.exists(timeout=2):82 main2.set_focus83else:84 for i in range(30):85 try:86 app.set_focus()87 keyboard.send_keys('^%e')88 main2.set_focus()89 break90 except Exception as e:91 pass9293sleep(10)94keyboard.send_keys('^c')9596win32clipboard.OpenClipboard()97got = win32clipboard.GetClipboardData()98win32clipboard.CloseClipboard()99grid = got.splitlines()100grid.pop(0)101102for estad in data['name_stad']:103 index = 0104 flag = False105 for i in grid:106 if estad in i:107 flag = True108 break109 index += 1110 if not flag:111 print(f"Estadistic Not Found {estad}")112 continue113114 print(f"Estadistic Found {estad}")115116 keyboard.send_keys('{HOME}')117118 for i in range(index):119 keyboard.send_keys('{DOWN}')120121 keyboard.send_keys('{ENTER}')122123 sleep(8)124125 error = app.window(title="Error")126 127 if error.exists(timeout=3):128 app['Error']['Button'].click()129 continue130131132 sleep(10)133 134 ven=app.window(title="Estadísticas de ventas")135 if ven.exists:136 pass137 else:138 ven=app.window(title="Estadísticas de facturas")139 if ven.exists:140 pass141 else:142 ven=app.window(title="Estadísticas de productos")143 if ven.exists:144 pass145 else:146 print("Estadística no accesible")147 continue148149 keyboard.send_keys('^e')150151 export_info=app.window(title="Exportar información")152153 if export_info.exists(timeout=2):154 app['Exportar información']['ComboBox2'].type_keys("%{DOWN}")155 app['Exportar información']['ComboBox2'].type_keys(data['formato'])156 app['Exportar información']['ComboBox2'].click()157 app['Exportar información']['Button6'].click()158 159 app['Exportar Información']['Edit7'].type_keys(data['repositorio'], with_spaces=True)160 app['Exportar información']['Button3'].click()161162 error2 = app.window(title="Error")163 if error2.exists(timeout=5):164 app['Error']['Button'].click()165 app['Exportar Información']['Edit7'].type_keys(data['repositorio_pre'], with_spaces=True)166 app['Exportar información']['Button3'].click()167168 confi=app.window(title="Confirmación")169 if confi.exists(timeout=2):170 app['Confirmación']['Button1'].click()171172 sleep(8)173174 info=app.window(title="Información")175 if info.exists(timeout=2):176 app['Información']['Button'].click()177 178 if main2.exists(timeout=2):179 main2.set_focus180 else:181 for i in range(30):182 try:183 main.set_focus()184 keyboard.send_keys('^%e')185 main2.set_focus()186 break187 except Exception as e:188 pass189190sleep(5)191 192keyboard.send_keys('%{F4}')193194sleep(5)195196confi2=app.window(title="Confirmación")197if confi2.exists(timeout=2):198 app['Confirmación']['Button1'].click()199 ...

Full Screen

Full Screen

proxy_app.py

Source:proxy_app.py Github

copy

Full Screen

...41 os.environ.update({"__COMPAT_LAYER":"RUnAsInvoker"})42 app = Application().start('C:\\3.26\\Client.exe')43 sleep(2)44 w = app.top_window()45 w.set_focus()46 sleep(2)47 sleep(1)48 w.set_focus()49 sleep(0.5)50 user_id = 'olorus'51 password = 'gP2{^}5yY4htLS'52 w.set_focus()53 sleep(0.3)54 for i in range(15):55 sleep(0.1)56 keyboard.send_keys('{DELETE}')57 sleep(2)58 w.set_focus()59 sleep(0.3)60 keyboard.send_keys(user_id)61 sleep(1)62 w.set_focus()63 sleep(0.3)64 keyboard.send_keys('{TAB 1}')65 sleep(1)66 for i in range(15):67 sleep(0.1)68 keyboard.send_keys('{DELETE}')69 sleep(1)70 w.set_focus()71 sleep(0.3)72 keyboard.send_keys(password)73 sleep(1)74 w.set_focus()75 sleep(0.2)76 keyboard.send_keys('{TAB 1}')77 keyboard.send_keys('{TAB 1}')78 sleep(1)79 w.set_focus()80 sleep(0.2)81 keyboard.send_keys('{ENTER 2}')82 sleep(1)83 sleep(2)84 sleep(1)85 try:86 app_b = Application().connect(path='annoucement.exe')87 w_b = app_b.top_window()88 w_b.close()89 sleep(1)90 except:91 pass92 sleep(2)93 sleep(1)94 except:95 pass96 sleep(2)97 # os.popen('"C:/Users/olorus/Downloads/3.26/ProxyTool/AutoProxyTool.exe" -changeproxy/PT')98 sleep(3)99 sleep(2)100 app1 = Application().connect(path='Client.exe')101 w1 = app1.top_window()102 w1.set_focus()103 sleep(2)104 w1.set_focus()105 os.popen('"C:/3.26/ProxyTool/AutoProxyTool.exe" -changeproxy/CH')106 print('done proxy ip change')107 sleep(3)108 # os.popen('"C:/3.26/ProxyTool/AutoProxyTool.exe" -changeproxy/PT')109 # sleep(3)110 sleep(2)111 sleep(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 toolium 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