Best Python code snippet using SeleniumBase
main.py
Source: main.py
1import json2import os3import platform4import shutil5import subprocess6import time7import sys8import time as tm9import webbrowser10from threading import Thread11from PIL import Image12from pystray import Icon, Menu, MenuItem13class ControlTiempo(Thread):14 def __init__(self, icon, controlHilos, contenido, tiempoActualizar, rutaNueva=None):15 super().__init__()16 self.icon = icon17 self.controlHilos = controlHilos18 self.contenido = contenido19 self.tiempoActualizar = tiempoActualizar20 self.rutaNueva = rutaNueva21 self.contenidoPath = None22 self.rutaActual = None23 self.revisandoRutas()24 self.tiempoActual = tm.time()25 def revisandoRutas(self):26 if self.rutaNueva is None:27 self.contenidoPath = os.listdir()28 else:29 self.contenidoPath = os.listdir(self.rutaNueva)30 self.rutaActual = os.getcwd()31 def revisarCarpetas(self):32 for carpetas in self.contenido.keys():33 if not os.path.exists(f"{self.rutaActual}\\{self.contenido[carpetas]['source']}"):34 os.mkdir(f"{self.rutaActual}\\{self.contenido[carpetas]['source']}")35 def revisarExtenciones(self):36 for carpetas in self.contenido.keys():37 extenciones = self.contenido[carpetas]["extencion"]38 rutaMover = self.contenido[carpetas]["source"]39 for ext in extenciones:40 for elementos in self.contenidoPath:41 if ext in elementos.lower() and not elementos.lower() == "orderdowloads.exe":42 if self.rutaNueva is None:43 shutil.move(f"{self.rutaActual}\\{elementos}", f"{self.rutaActual}\\{rutaMover}")44 else:45 shutil.move(f"{self.rutaNueva}\\{elementos}", f"{self.rutaActual}\\{rutaMover}")46 self.revisandoRutas()47 def iniciar(self):48 self.revisandoRutas()49 self.revisarCarpetas()50 self.revisarExtenciones()51 self.icon.notify("Se han guardado todos los elementos", "Aviso de Ejecución")52 def run(self):53 self.iniciar()54 while self.controlHilos[0]:55 tiempoTranscurrido = tm.time()56 tiempo = tiempoTranscurrido - self.tiempoActual57 if not self.controlHilos[0]:58 break59 if tiempo >= 60 * self.tiempoActualizar:60 self.tiempoActual = tm.time()61 self.iniciar()62 time.sleep(5)63class OrderDowloads():64 def __init__(self):65 archivo = open("Config.json", encoding="utf-8")66 self.contenido = json.load(archivo)67 archivo.close()68 self.controlHilos = [self.contenido["Aplicacion"]["enMovimiento"], ]69 self.tiempoActualizar = self.contenido["Aplicacion"]["actualizacion"]70 self.rutaNueva = self.contenido["Aplicacion"]["source_new"]71 self.icon = Icon("OrderDowloads", Image.open("icon.jpeg"), menu=Menu(72 MenuItem("Abrir", Menu(MenuItem("Abrir Contenedor", self.abrirContenedor),73 MenuItem("Abrir Documentos", self.abrirDocumentos),74 MenuItem("Abrir Videos", self.abrirVideos),75 MenuItem("Abrir Imagenes", self.abrirImagenes),76 MenuItem("Abrir Sonidos", self.abrirSonidos),77 MenuItem("Abrir Comprimidos", self.abrirComprimidos),78 MenuItem("Abrir ImagenISO", self.abrirImagenISO),79 MenuItem("Abrir Programas", self.abrirProgramas),80 MenuItem("Abrir Otros", self.abrirContenedor)81 )),82 MenuItem("Ejecutar Ahora", self.actualizar),83 MenuItem("Configuración", self.configurar),84 MenuItem("Creditos", self.creditos),85 MenuItem("Salir", self.salir)86 ))87 if len(self.rutaNueva) >= 1:88 self.controlTiempo = ControlTiempo(self.icon, self.controlHilos, self.contenido["Configuracion"],89 self.tiempoActualizar,90 rutaNueva=self.rutaNueva)91 else:92 self.controlTiempo = ControlTiempo(self.icon, self.controlHilos, self.contenido["Configuracion"],93 self.tiempoActualizar)94 def configurar(self):95 self.icon.notify("Aun no esta completo este modulo, por favor modifica en el contendor el archivo 'Config.json'", "Error de inicio de Bloque")96 def abrirProgramas(self):97 self.abrirArchivo("Programas")98 def abrirImagenISO(self):99 self.abrirArchivo("ImagenISO")100 def abrirSonidos(self):101 self.abrirArchivo("Sonidos")102 def abrirComprimidos(self):103 self.abrirArchivo("Comprimidos")104 def abrirImagenes(self):105 self.abrirArchivo("Imagenes")106 def actualizar(self):107 self.controlTiempo.iniciar()108 def creditos(self):109 self.icon.notify("Esta aplicación fue escrita por Mau005", "Creditos: ")110 webbrowser.open("https://github.com/Mau005")111 def abrirDocumentos(self):112 self.abrirArchivo("Documentos")113 def abrirVideos(self):114 self.abrirArchivo("Video")115 def abrirContenedor(self):116 self.abrirArchivo()117 def abrirArchivo(self, carpeta=None):118 if carpeta is None:119 path = self.controlTiempo.rutaActual120 else:121 path = self.controlTiempo.rutaActual + "/" + carpeta122 if platform.system().lower() == "darwin":123 subprocess.Popen(["open", path])124 elif platform.system().lower() == "windows":125 os.startfile(path)126 else:127 subprocess.Popen(["xdg-open", path])128 def salir(self):129 self.controlHilos[0] = False130 self.icon.notify("Se ha cerrado la aplicaciòn Vuelve pronto", "Salida")131 self.icon.stop()132 def iniciar(self):133 self.controlTiempo.start()134 self.icon.notify("Se iniciado OrderDowloads Correctamente", "Mensaje de Inicio")135 self.icon.run()136if __name__ == "__main__":137 app = OrderDowloads()...
trabbajo.py
Source: trabbajo.py
1import cv22import image3from PIL import Image4from tkinter import *5import numpy as np6ABRIR_WINDOW=Tk()7ABRIR_WINDOW.geometry('636x351')8ABRIR_WINDOW.title('TOMADOR DE FOTOGRAFIA')9jojo= PhotoImage(file ='konohha.png')10fondo=Label(ABRIR_WINDOW,image=jojo).place(x=0,y=0)11def close_window():12 ABRIR_WINDOW.destroy()13def TOMAR_FOTOGRAFIA():14 camara = cv2.VideoCapture(0)15 leido,frame = camara.read()16 if leido == True:17 cv2.imwrite('fotografia.png',frame)18 labilo=Label(ABRIR_WINDOW,text='LA FOTOGRAFIA SE HIZO CON EXITO')19 labilo.place(x=240,y=170)20 Label(ABRIR_WINDOW,text='abriendo imagen').place(x=240,y=120)21 imagen = cv2.imread('fotografia.png',1)22 prro = cv2.imshow('imagen Abierta',imagen)23 PREGUNTA=Label(ABRIR_WINDOW,text='¿QUIERES INTERTARLO DE NUEVO?')24 PREGUNTA.place(x=320,y=30)25 26 monitor = Label(ABRIR_WINDOW)27 monitor.pack()28 opcion = IntVar()29 DECISION=Radiobutton(ABRIR_WINDOW,text='SI',variable= opcion, command = TOMAR_FOTOGRAFIA)30 DECISION.place(x=360,y=70)31 bton=Radiobutton(ABRIR_WINDOW,text='NO',variable = opcion, command= quit)32 bton.place(x=400,y=70)33 camara.release()34bton=Button(ABRIR_WINDOW,text='TOMAR FOTOGRAFIA',command=TOMAR_FOTOGRAFIA)35bton.place(x=40,y=30)36bton_2=Button(ABRIR_WINDOW,text='SALIR DEL PROGRAMA',command= close_window)37bton_2.place(x=40,y=100)3839
...
Check out the latest blogs from LambdaTest on this topic:
The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.
Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.
In general, software testers have a challenging job. Software testing is frequently the final significant activity undertaken prior to actually delivering a product. Since the terms “software” and “late” are nearly synonymous, it is the testers that frequently catch the ire of the whole business as they try to test the software at the end. It is the testers who are under pressure to finish faster and deem the product “release candidate” before they have had enough opportunity to be comfortable. To make matters worse, if bugs are discovered in the product after it has been released, everyone looks to the testers and says, “Why didn’t you spot those bugs?” The testers did not cause the bugs, but they must bear some of the guilt for the bugs that were disclosed.
Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
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!!