0

I have this function:

def add_key():
    driver.find_element_by_name('key').send_keys('first_bonus')
    driver.find_element_by_name('translation').send_keys('First Bonus')

...

add_key()

Now I want to be able to send_keys and rename them in the future ('first_bonus' and 'First Bonus') when calling the function itself add_key() not inside the function. But I don't want the send_keys("") to be visible when caling the function, just the name of the key and translation. Is it possible?

3
  • 1
    Why don't you just add arguments in the function header, and use send_keys(argument_1) for example? Commented Sep 17, 2020 at 10:09
  • Thanks a lot! I'm still learning so didn't think of this! Helped me a lot! Commented Sep 17, 2020 at 10:20
  • 1
    No problemo, glad to be of help :) Commented Sep 17, 2020 at 10:21

1 Answer 1

1

I guess you need to make it dynamic with arguments

def add_key(element_name, text):
    driver.find_element_by_name(element_name).send_keys(text)
add_key('key','first_bonus')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.