Bot does not enter values within the def function, using send Keys command with the Selenium driver

Asked

Viewed 37 times

-1

I am creating an automated design using the Selenium driver. I’m starting with Python actually, and when I create the def function below, it’s locating the elements but it’s not typing the values. If I do the direct code without the def, it types, but within the def function is not typing. I believe you’re failing to do something important.

Follow the code below.

browser = webdriver.Chrome(
    executable_path=r'C:\Users\rogerio.junior\Documents\Projetos 
Python\Meu_Progama\chromedriver.exe')
browser.get('https://pegasus/Rekrut/Logon/LoginManual')

sleep(2)

browser.maximize_window()

sleep(2)
def Entrar(Login, Senha):
    browser.find_element_by_id('Login').send_keys(Login)
    browser.find_element_by_id('Senha').send_keys(Senha)
    browser.find_element_by_class_name('btn').click()

    Entrar("Valorx", "Valory")

1 answer

0

If the indentation is according to the posted question, adjust your code to:

def Entrar(Login, Senha):
    browser.find_element_by_id('Login').send_keys(Login)
    browser.find_element_by_id('Senha').send_keys(Senha)
    browser.find_element_by_class_name('btn').click()

Entrar("Valorx", "Valory")

You must "go back" (remove) 4 spaces in the function call Entrar.

  • It worked, just put the function that had created correctly then. Thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.