Best Python code snippet using SeleniumBase
ArbolAVLDB.py
Source:ArbolAVLDB.py
...13 def get_right(self):14 return self.__right15 def set_element(self, element):16 self.__element = element17 def get_element(self):18 return self.__element19 def set_factor(self, factor):20 self.__factor = factor21 def get_factor(self):22 return self.__factor23class ArbolAVLT:24 def __init__(self):25 self.root: NodoAVL = None26 self.cadena = ""27 self.__list_tables = list()28 def add(self, element):29 self.root = self.__add(self.root, element)30 def __add(self, raiz: NodoAVL, element):31 if raiz is None:32 raiz = NodoAVL(element)33 elif element.get_table_name() < raiz.get_element().get_table_name():34 left = self.__add(raiz.get_left(), element)35 raiz.set_left(left)36 elif element.get_table_name() > raiz.get_element().get_table_name():37 right = self.__add(raiz.get_right(), element)38 raiz.set_right(right)39 raiz.set_factor(1 + max(self.__get_height(raiz.get_left()), self.__get_height(raiz.get_right())))40 balance = self.__get_balance(raiz)41 if balance > 1 and element.get_table_name() < raiz.get_left().get_element().get_table_name():42 return self.__rotacion_right(raiz)43 if balance < -1 and element.get_table_name() > raiz.get_right().get_element().get_table_name():44 return self.__rotacion_left(raiz)45 if balance > 1 and element.get_table_name() > raiz.get_left().get_element().get_table_name():46 rotate = self.__rotacion_left(raiz.get_left())47 raiz.set_left(rotate)48 return self.__rotacion_right(raiz)49 if balance < -1 and element.get_table_name() < raiz.get_right().get_element().get_table_name():50 rotate = self.__rotacion_right(raiz.get_right())51 raiz.set_right(rotate)52 return self.__rotacion_left(raiz)53 return raiz54 def __get_height(self, root: NodoAVL):55 if not root:56 return 057 return root.get_factor()58 def __rotacion_left(self, z: NodoAVL):59 y: NodoAVL = z.get_right()60 t2: NodoAVL = y.get_left()61 y.set_left(z)62 z.set_right(t2)63 z.set_factor(1 + max(self.__get_height(z.get_left()), self.__get_height(z.get_right())))64 y.set_factor(1 + max(self.__get_height(y.get_left()), self.__get_height(y.get_right())))65 return y66 def __rotacion_right(self, z: NodoAVL):67 y: NodoAVL = z.get_left()68 t3 = y.get_right()69 y.set_right(z)70 z.set_left(t3)71 z.set_factor(1 + max(self.__get_height(z.get_left()), self.__get_height(z.get_right())))72 y.set_factor(1 + max(self.__get_height(y.get_left()), self.__get_height(y.get_right())))73 return y74 def __get_balance(self, raiz: NodoAVL):75 if not raiz:76 return 077 return self.__get_height(raiz.get_left()) - self.__get_height(raiz.get_right())78 def grafica(self):79 self.cadena = "digraph G{\n"80 self.cadena += "node[shape=\"record\"]\n"81 if self.root is not None:82 self.cadena += f"node{self.root.get_element().get_table_name()}[color=\"#000000\",label=\"<f0>|<f1> Valor:{self.root.get_element().get_table_name()} |<f2>\" ] \n"83 self.__graficar(self.root, self.get_root().get_left(), True)84 self.__graficar(self.root, self.get_root().get_right(), False)85 self.cadena += "}\n"86 print(self.cadena)87 return self.cadena88 def get_root(self):89 return self.root90 def __graficar(self, padre, actual, left):91 if actual is not None:92 self.cadena += f"node{actual.get_element().get_table_name()}[color=\"#000000\",label=\"<f0>|<f1> Valor:{actual.get_element().get_table_name()} |<f2>\"] \n"93 if left is True:94 self.cadena += f"node{padre.get_element().get_table_name()}:f0->node{actual.get_element().get_table_name()}:f1 [arrowhead=\"crow\",color=\"#E30101 \"] \n"95 else:96 self.cadena += f"node{padre.get_element().get_table_name()}:f2->node{actual.get_element().get_table_name()}:f1 [arrowhead=\"crow\",color=\"#E30101 \"] \n"97 self.__graficar(actual, actual.get_left(), True)98 self.__graficar(actual, actual.get_right(), False)99 def __delete_nodo(self, raiz, value):100 if not raiz: return raiz101 if value < str(raiz.get_element().get_table_name()):102 left = self.__delete_nodo(raiz.get_left(), value)103 raiz.set_left(left)104 elif value > str(raiz.get_element().get_table_name()):105 right = self.__delete_nodo(raiz.get_right(), value)106 raiz.set_right(right)107 else:108 if raiz.get_left() is None:109 temp = raiz.get_right()110 raiz = None111 return temp112 elif raiz.get_right() is None:113 temp = raiz.get_left()114 raiz = None115 return temp116 small_value = self.__find_nodo(raiz.get_right())117 raiz.set_element(small_value)118 right = self.__delete_nodo(raiz.get_right(), small_value.get_table_name())119 raiz.set_right(right)120 if raiz is None:121 return raiz122 raiz.set_factor(1 + max(self.__get_height(raiz.get_left()), self.__get_height(raiz.get_right())))123 balance = self.__get_balance(raiz)124 if balance > 1 and self.__get_balance(raiz.get_left()) >= 0:125 return self.__rotacion_right(raiz)126 if balance < -1 and self.__get_balance(raiz.get_right()) <= 0:127 return self.__rotacion_left(raiz)128 if balance > 1 and self.__get_balance(raiz.get_left()) < 0:129 left = self.__rotacion_left(raiz.get_left())130 raiz.set_left(left)131 return self.__rotacion_right(raiz)132 if balance < -1 and self.__get_balance(raiz.get_right()) > 0:133 right = self.__rotacion_right(raiz.get_right())134 raiz.set_right(right)135 return self.__rotacion_left(raiz)136 return raiz137 def delete_nodo(self, value):138 self.root = self.__delete_nodo(self.root, value)139 def __find_nodo(self, raiz=NodoAVL):140 if raiz.get_left() is None:141 return raiz.get_element()142 else:143 return self.__find_nodo(raiz.get_left())144 def __search_value(self, root, name):145 if root is None: return None146 if root.get_element().get_table_name() == name:147 return root148 if root.get_element().get_table_name() > name:149 return self.__search_value(root.get_left(), name)150 return self.__search_value(root.get_right(), name)151 def search_value(self, table_name):152 return self.__search_value(self.root, table_name)153 def update_table_pk(self, table_name, columns):154 aux: NodoAVL = self.root155 modify = False156 while not modify:157 if table_name == aux.get_element().get_table_name():158 aux.get_element().define_pk(columns)159 modify = True160 return True161 if table_name < aux.get_element().get_table_name():162 aux = aux.get_left()163 if table_name > aux.get_element().get_table_name():164 aux = aux.get_right()165 return False166 def __update_table_pk_r(self, root: NodoAVL, table_name, columns):167 if root is None: return None168 if root.get_element().get_table_name() == table_name:169 return root.get_element().define_pk(columns)170 if root.get_element().get_table_name() > table_name:171 return self.__update_table_pk_r(root.get_left(), table_name, columns)172 return self.__update_table_pk_r(root.get_right(), table_name, columns)173 def update_table_pk_r(self, table_name, columns):174 return self.__update_table_pk_r(self.root, table_name, columns)175 def update_alter_add_column(self, table_name):176 return self.__update_alter_add_column(self.root, table_name)177 def __update_alter_add_column(self, root, table_name):178 if root is None: return None179 if root.get_element().get_table_name() == table_name:180 root.get_element().add_column()181 return True182 if root.get_element().get_table_name() > table_name:183 return self.__update_alter_add_column(root.get_left(), table_name)184 return self.__update_alter_add_column(root.get_right(), table_name)185 def insert_tupla(self, table_name, register):186 return self.__insert_tupla(self.root, table_name, register)187 def __insert_tupla(self, root: NodoAVL, table_name, register):188 if root is None: return None189 if table_name == root.get_element().get_table_name():190 status = root.get_element().insert(register)191 return status192 if root.get_element().get_table_name() > table_name:193 return self.__insert_tupla(root.get_left(), table_name, register)194 return self.__insert_tupla(root.get_right(), table_name, register)195 def extract_row(self, table_name, columns):196 return self.__extract_row(self.root, table_name, columns)197 def __extract_row(self, root: NodoAVL, table_name, columns):198 if root is None: return None199 if table_name == root.get_element().get_table_name():200 return root.get_element().extractRow(columns)201 if root.get_element().get_table_name() > table_name:202 return self.__extract_row(root.get_left(), table_name, columns)203 return self.__extract_row(root.get_right(), table_name, columns)204 def get_tables(self):205 self.__inorder(self.root)206 list_aux = self.__list_tables207 self.__list_tables = list()208 return list_aux209 def __inorder(self, nodo):210 if nodo.get_left() is not None:211 self.__inorder(nodo.get_left())212 self.__list_tables.append(nodo.get_element().get_table_name())213 if nodo.get_right() is not None:214 self.__inorder(nodo.get_right())215 def load_csv(self, table_name, file):216 return self.__load_csv(self.root, table_name, file)217 def __load_csv(self, root: NodoAVL, table_name, file):218 if root is None: return None219 if table_name == root.get_element().get_table_name():220 return root.get_element().loadCSV(file)221 if root.get_element().get_table_name() > table_name:222 return self.__load_csv(root.get_left(), table_name, file)223 return self.__load_csv(root.get_right(), table_name, file)224 def update(self, table_name, register, columns):225 return self.__update(self.root, table_name, register, columns)226 def __update(self, root: NodoAVL, table_name, register, columns):227 if root is None: return None228 if table_name == root.get_element().get_table_name():229 return root.get_element().update(register, columns)230 if root.get_element().get_table_name() > table_name:231 return self.__update(root.get_left(), table_name, register, columns)232 return self.__update(root.get_right(), table_name, register, columns)233 def delete_register(self, table_name, columns):234 return self.__delete_register(self.root, table_name, columns)235 def __delete_register(self, root: NodoAVL, table_name, columns):236 if root is None: return None237 if table_name == root.get_element().get_table_name():238 return root.get_element().delete(columns)239 if root.get_element().get_table_name() > table_name:240 return self.__delete_register(root.get_left(), table_name, columns)241 return self.__delete_register(root.get_right(), table_name, columns)242 def truncate(self, table_name):243 return self.__truncate(self.root, table_name)244 def __truncate(self, root: NodoAVL, table_name):245 if root is None: return None246 if table_name == root.get_element().get_table_name():247 root.get_element().truncate()248 return True249 if root.get_element().get_table_name() > table_name:250 return self.__truncate(root.get_left(), table_name)251 return self.__truncate(root.get_right(), table_name)252 def alter_drop_pk(self, table_name):253 return self.__alter_drop_pk(self.root, table_name)254 def __alter_drop_pk(self, root: NodoAVL, table_name):255 if root is None: return None256 if table_name == root.get_element().get_table_name():257 return root.get_element().alterDropPK()258 if root.get_element().get_table_name() > table_name:259 return self.__alter_drop_pk(root.get_left(), table_name)260 return self.__alter_drop_pk(root.get_right(), table_name)261 def alterAddColumn(self, table_name, default):262 return self.__alterAddColumn(self.root, table_name, default)263 def __alterAddColumn(self, root: NodoAVL, table_name, default):264 if root is None: return None265 if table_name == root.get_element().get_table_name():266 status = root.get_element().alterAddColumn(default)267 return status268 if root.get_element().get_table_name() > table_name:269 return self.__alterAddColumn(root.get_left(), table_name, default)270 return self.__alterAddColumn(root.get_right(), table_name, default)271 def alterDropColumn(self, table_name, columnNumber):272 return self.__alterDropColumn(self.root, table_name, columnNumber)273 def __alterDropColumn(self, root: NodoAVL, table_name, columnNumber):274 if root is None: return None275 if table_name == root.get_element().get_table_name():276 status = root.get_element().alterDropColumn(columnNumber)277 return status278 if root.get_element().get_table_name() > table_name:279 return self.__alterDropColumn(root.get_left(), table_name, columnNumber)...
location_admin_add_activity_page.py
Source:location_admin_add_activity_page.py
2class LocationAdminAddActivityPage(object):3 def __init__(self,driver):4 self.fe = FindElement(driver)5 def get_activity_menu(self):6 return self.fe.get_element('activity_model')7 def get_activity_management(self):8 return self.fe.get_element('activity_list')9 def get_activity_add_btn(self):10 return self.fe.get_element('activity_addbtn')11 def get_activity_title(self):12 return self.fe.get_element('activity_title')13 def get_activity_type_input(self):14 return self.fe.get_element('activity_type_input')15 def get_activity_type(self):16 return self.fe.get_element('activity_type')17 def get_activity_time_input(self):18 return self.fe.get_element('activity_time_input')19 def get_activity_start_time(self):20 return self.fe.get_element('activity_start')21 def get_activity_end_time(self):22 return self.fe.get_element('activity_end')23 def get_activity_time_confirm(self):24 return self.fe.get_element('activity_time_sub')25 def get_activity_singup_by_end_input(self):26 return self.fe.get_element('activity_sign_date_input')27 def get_activity_signup_by_end_next_month(self):28 return self.fe.get_element('activity_sign_date_next_month')29 def get_activity_singup_by_end_time(self):30 return self.fe.get_element('activity_sign_date')31 def get_activity_space(self):32 return self.fe.get_element('activity_space')33 def get_activity_tickets(self):34 return self.fe.get_element('activity_ticket')35 def get_activity_top(self):36 return self.fe.get_element('activity_top')37 def get_activity_notop(self):38 return self.fe.get_element('activity_notop')39 def get_activity_uploadpic(self):40 return self.fe.get_element('activity_pic')41 def get_activity_note(self):42 return self.fe.get_element('activity_note')43 def get_activity_add_release(self):44 return self.fe.get_element('activity_release')45 def get_activity_add_draft(self):46 return self.fe.get_element('activity_draft')47 def get_form_tip(self):48 return self.fe.get_element('page_error_msg')49 def get_server_tip(self):...
front_operation_visitor_page.py
Source:front_operation_visitor_page.py
2class FrontOperationVisitorPage(object):3 def __init__(self,driver):4 self.fe = FindElement(driver)5 def get_visitor_menu(self):6 return self.fe.get_element('visitor_module')7 def get_visitor_list(self):8 return self.fe.get_element('visitor_list')9 def get_visitor_info(self):10 return self.fe.get_element('')11 def get_approval_button(self):12 return self.fe.get_element()13 def get_approval_confirm_button(self):14 return self.fe.get_element('')15 def get_back_list_button(self):16 return self.fe.get_element('')17 def get_select_all_list(self):18 return self.fe.get_element('')19 def get_approval_all_button(self):20 return self.fe.get_element('')21 def get_first_sign_button(self):22 return self.fe.get_element('')23 def get_sign_confirm_button(self):24 return self.fe.get_element('')25 def get_sign_all_button(self):26 return self.fe.get_element('')27 def get_sign_out_button(self):28 return self.fe.get_element('')29 def get_sign_out_all_button(self):30 return self.fe.get_element('')31 def get_more_button(self):32 return self.fe.get_element('')33 def get_delect_button(self):34 return self.fe.get_element('')35 def get_delect_confirm_button(self):...
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!!