Best Python code snippet using SeleniumBase
Algoritmo.py
Source: Algoritmo.py
1from random import randint2from time import sleep3import sys4import os5lista = [] #cria uma lista de valores com nenhum valor inserido6dormir_c = False #flag para desativar/ativar processo B (consumidor)7dormir_p = False #flag para desativar/ativar processo A (produtor)8length_max = int(sys.argv[1]) #tamanho max do vetor9#Processo A (produtor), produz valores para a lista10def produtor():11 global lista, length_max, dormir_c, dormir_p12 if not dormir_p: #verifica se processo está ativo13 while len(lista) < length_max: #verifica se a lista não atingiu seu tamanho máximo14 lista.append(randint(0, 1000)) #adiciona um valor inteiro entre 0 e 1000 à lista15 print('Olá Sr. Programador eu sou o produtor, olha como está a lista de valores ' + str(lista))16 else:17 print('Fiz o meu serviço olha como eu deixei a lista cheinha >>> ' + str(lista))18 print('Agora eu vou tirar uma soneca. [Produtor está tirando uma soneca acorde ele quando a lista estiver vazia] \n')19 dormir_p = True #desativa o processo A20 dormir_c = False #ativa o processo B21 consumidor() #chama o consumidor22#Processo B (consumidor), consome valores da lista 23def consumidor():24 global lista, length_max, dormir_c, dormir_p25 if not dormir_c: #verifica se processo está ativo26 if lista: #verifica se a lista contem valores27 del lista[0] #remove o valor que se encontra no inicio da lista28 print('Olá Sr. Programador eu sou o consumidor, olha como está a lista de valores' + str(lista))29 else:30 print('Fiz o meu serviço olha como eu deixei a lista limpinha >>> ' + str(lista))31 print('Agora eu vou tirar uma soneca. [Consumidor está tirando uma soneca, acorde ele quando a lista possuir valores] \n')32 dormir_c = True #desativa o processo B33 dormir_p = False #ativa o processo A34 produtor() #chama o produtor35while True: #loop infinito36 #inicia a brincadeira37 produtor() 38 consumidor()39 sleep(5) #trava a tela a cada iteração para podermos ver os processos em execução...
test.py
Source: test.py
1# -*- coding: utf-8 -*-2import threading3from time import sleep4acordar_dormir_produtor = threading.Event()5acordar_dormir_consumidor = threading.Event()6bufer = 07bufer_max = 108def consumidor():9 global acordar_dormir_produtor10 global acordar_dormir_consumidor11 global bufer12 global bufer_max13 while True:14 if bufer == 0:15 print ("consumidor dormindo")16 acordar_dormir_produtor.clear()17 acordar_dormir_consumidor.wait()18 print ("consumidor acordou")19 bufer = bufer - 120 if bufer == (bufer_max - 1):21 print ("distracando produtor")22 acordar_dormir_produtor.set()23 print ("consumidor",bufer)24 sleep(1)25def produtor():26 global acordar_dormir_produtor27 global acordar_dormir_consumidor28 global bufer29 global bufer_max30 while True:31 if bufer == bufer_max:32 print ("produtor dormindo")33 acordar_dormir_produtor.clear()34 acordar_dormir_produtor.wait()35 print ("produtor acordou")36 bufer = bufer + 137 if bufer == 1:38 print ("distracando consumidor")39 acordar_dormir_consumidor.set()40 print ("produtor ",bufer)41 sleep(1)42print (bufer)43b = threading.Thread(target=produtor)44a = threading.Thread(target=consumidor)45a.start()46b.start()47#while True:48 # time.sleep(3)...
aluno.py
Source: aluno.py
...5 6 def estudar(self,horas):7 self.tempo_sem_dormir += horas8 9 def dormir(self,horas):10 self.tempo_sem_dormir -= horas11aluno1 = Aluno()12aluno1.nome = "Luizinho" 13aluno1.estudar(3)14aluno1.dormir(2)15aluno1.estudar(4)16aluno1.dormir(2)...
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!!