How to use encontrar_elemento method in SeleniumBase

Best Python code snippet using SeleniumBase

resultados.py

Source:resultados.py Github

copy

Full Screen

...9 """10 Esse método seleciona o segundo turno no menu principal11 :return: None12 """13 drop_down_eleicoes = Base.encontrar_elemento(self.drive, ResultadosSeletores.DROP_DOWN_ELEICOES)14 drop_down_eleicoes.click()15 btn_2_turno = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_2_TURNO)16 btn_2_turno.click()17 def escolher_local(self):18 """19 Esse método clica na escolha de um local de votação20 :return: None21 """22 Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_2_TURNO)23 btn_escolher_local = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_ESCOLHER_LOCAL)24 btn_escolher_local.click()25 def escolher_estado_municipio(self, estado, municipio):26 """27 Esse método escolhe o estado e municipio de votação28 :param estado: estado value29 :param municipio: municipio value30 :return: None31 """32 btn_estado = Base.encontrar_elemento(self.drive, ResultadosSeletores.DROP_DOWN_ESTADO)33 btn_estado.click()34 os.system('adb shell input swipe 500 1000 500 0')35 drop_seleciona_estado = Base.encontrar_elemento(self.drive, estado)36 drop_seleciona_estado.click()37 btn_confirma = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_CONFIRMAR_LOCAL)38 btn_confirma.click()39 drop_seleciona_municipio = Base.encontrar_elemento(self.drive, ResultadosSeletores.DROP_DOWN_MUNICIPIO)40 drop_seleciona_municipio.click()41 btn_municipio = Base.encontrar_elemento(self.drive, municipio)42 btn_municipio.click()43 btn_confirma.click()44 btn_confirma.click()45 def recife_pe_2_turno_validacao(self):46 """47 Esse método valida que o municipio escolhido foi exibido corretamente48 :return: boolean49 """50 try:51 wait = WebDriverWait(self.drive, 15)52 wait.until(EC.presence_of_element_located(ResultadosSeletores.HOME_TEXTO_RECIFE))53 except NoSuchElementException:54 return False55 return True56 def favoritar_candidato(self):57 """58 Esse método favorita um candidato59 :return: None60 """61 os.system('adb shell input swipe 500 1000 500 0')62 texto_marilia = Base.encontrar_elemento(self.drive, ResultadosSeletores.CANDIDATO_TEXTO_MARILIA)63 texto_marilia.click()64 btn_favoritar = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_FAVORITAR)65 btn_favoritar.click()66 def valida_favorito(self):67 """68 Esse método valida se o candidato foi favoritado corretamente na tela de detalhes do candidato69 :return: boolean70 """71 try:72 wait = WebDriverWait(self.drive, 15)73 wait.until(EC.presence_of_element_located(ResultadosSeletores.FAVORITO_TEXTO))74 except NoSuchElementException:75 return False76 return True77 def valida_favorito_tab(self):78 """79 Esse método valida se o candidato favoritado foi exibido na tab de favoritos80 :return: boolean81 """82 try:83 btn_fechar = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_FECHAR)84 btn_fechar.click()85 tab_favoritos = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_FAVORITOS_TAB)86 tab_favoritos.click()87 wait = WebDriverWait(self.drive, 15)88 wait.until(EC.presence_of_element_located(ResultadosSeletores.CANDIDATO_TEXTO_MARILIA))89 except NoSuchElementException:90 return False91 return True92 def busca_1_turno(self):93 """94 Esse método realiza a busca de um candidato do primeiro turno95 :return: None96 """97 btn_resultados = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_RESUL)98 btn_resultados.click()99 btn_escolhe_turno = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_ESCOLHE_TURNO_TOP)100 btn_escolhe_turno.click()101 dialog_turno = Base.encontrar_elemento(self.drive, ResultadosSeletores.DIALOG_1_TURNO)102 dialog_turno.click()103 btn_confirma = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_CONFIRMAR_TURNO)104 btn_confirma.click()105 btn_pesquisar_candidato = Base.encontrar_elemento(self.drive, ResultadosSeletores.BTN_PESQUISAR_CANDIDATO)106 btn_pesquisar_candidato.click()107 barra_busca = Base.encontrar_elemento(self.drive, ResultadosSeletores.BARRA_BUSCA)108 barra_busca.send_keys("dani")109 def valida_busca(self):110 """111 Esse método valida se a busca de um candidato do primeiro turno foi feita corretamente112 :return: boolean113 """114 try:115 wait = WebDriverWait(self.drive, 15)116 wait.until(EC.presence_of_element_located(ResultadosSeletores.RESULTADO_PESQUISA))117 except NoSuchElementException:118 return False...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...24 'botao_ram': '//*[@id="root"]/div/div[2]/div/div[2]/div[7]/div/div[2]/ul/li[4]/div/span',25 'botao_ram2': '//*[@id="root"]/div/div[2]/div/div[2]/div[7]/div/div[1]/ul/li[2]/div/span',26 'botao_ssd': '//*[@id="root"]/div/div[2]/div/div[2]/div[7]/div/div/ul/li[3]/div'27}28def encontrar_elemento(endereco):29 return navegador.find_element_by_xpath(url[endereco]).get_attribute('innerHTML')30def apertar_botao(elemento):31 return navegador.find_element_by_xpath(botoes[elemento]).click()32def navegar(site):33 return navegador.get(url[site])34def verificar_precos():35 navegar('Cotacao')36 cotacao = encontrar_elemento('BRL')37 navegar('Processador')38 pp = encontrar_elemento('Url_Processador')39 valor_processador = pp.split().pop(1)40 navegar('Placa_mae')41 pm = encontrar_elemento('Url_Placa_Mae')42 valor_placamae = pm.split().pop(1)43 navegar('Ram')44 apertar_botao('botao_ram')45 apertar_botao('botao_ram2')46 pr = encontrar_elemento('Url_ram')47 valor_ram = pr.split().pop(1)48 navegar('SSD')49 apertar_botao('botao_ssd')50 ps = encontrar_elemento('Url_ssd')51 valor_ssd = ps.split().pop(1)52 navegar('Fonte')53 pf = encontrar_elemento('Url_fonte')54 valor_fonte = pf.split().pop(1)55 # Planilha;56 pagina = book['Sheet']57 pagina.append(['Cotação do dia: ', cotacao])58 pagina.append(['Processador E5 2640 V3', valor_processador])59 pagina.append(['Placa Mãe x99 Machinist', valor_placamae])60 pagina.append(['Memória RAM 8GB 1866MHz', valor_ram])61 pagina.append(['SSD 512GB', valor_ssd])62 pagina.append(['Fonte Gamemax 650w', valor_fonte])63 book.save('Planilha.xlsx')64 65 print('Processo de escritura na Planilha concluído.')66 navegador.close()67verificar_precos()

Full Screen

Full Screen

Ses2_Functions_Ex1.py

Source:Ses2_Functions_Ex1.py Github

copy

Full Screen

...3######Functions4############56#Exercise 17'''Escribir una función llamada encontrar_elemento(secuencia,item)8que dada una secuencia y un ítem pasado por parámetros,9devuelve el valor true si encuentra el ítem dentro de la secuencia y false en caso contrario.'''1011'''print(encontrar_elemento([100,200,300,400],200)) #True12print(encontrar_elemento([100,200,300,400],400)) #True13print(encontrar_elemento([100,200,300,400],500)) #False '''1415#if both parameter should be inputted by the user:16def encontrar_elemento(serie,item):17 #print("This is the function to find an item into a serie.")18 if item in serie:19 #print("encontrar_elemento", item, "in: ", serie, "->", True)20 print(str(item), "is present on our list" )21 else:22 #print("encontrar_elemento", item, "in: ", serie, "->", False)23 print( str(item), "not found")24dayWeek =["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]25#encontrar_elemento(["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],"friday")26encontrar_elemento(dayWeek,"armand")27 ...

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 SeleniumBase 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