[Python] Criando um robo para testes

Discussão em 'Python' iniciado por Stack, Junho 5, 2025.

  1. Stack

    Stack Membro Participativo

    Quero criar um script python para clicar em um elemento por nome, no que eu estou errando?

    from SeleniumLibrary import SeleniumLibrary from selenium.webdriver.common.by import By

    class ElementoNaoEncontradoException(Exception): pass

    class CaptureElemento: def click_by_partial_text(self, text): from robot.libraries.BuiltIn import BuiltIn seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary') driver = seleniumlib.driver elements = driver.find_elements(By.TAG_NAME, "a") for el in elements: if text in el.text: driver.execute_script("arguments[0].scrollIntoView(true);", el) el.click() return raise ElementoNaoEncontradoException(f"Elemento com texto '{text}' não encontrado.")

    Continue reading...

Compartilhe esta Página