title: Passing variables to functions in Python
body: <p>Im writing test scripts in Python for Selenium web testing.</p>
  
  <p>How do I pass parameters through a Python function to call in a later function?
  I first have a login test function.
  Then I have a new user registration function. Im trying to pass the Username and Password I use in the registration function to the <code>testLogin()</code> function that I call inside the <code>testRegister()</code> function.</p>
  
  <p>This is my python code:</p>
  
  <pre><code>userName = "admin"
  password = "admin"
  
  #pass username and password variables to this function
  def testLogin(userName,password):
    browser = webdriver.Firefox()
    browser.get("http://url/login")
  
    element = browser.find_element_by_name("userName")
    element.send_keys(userName)
  
    element = browser.find_element_by_name("userPassword")
    element.send_keys(password)
  
    element.send_keys(Keys.RETURN)
  
    browser.close()
  
  # test registration
  def testRegister():
    browser = webdriver.Firefox()
    browser.get("http://url/register")
  
    #new username variable
    newUserName = "test"
    element = browser.find_element_by_name("regUser")
    element.send_keys(newUserName)
  
    #new password variable
    newUserPassword = "test"
    element = browser.find_element_by_name("regPassword")
    element.send_keys(newUserPassword)
  
    #
    #now test if user is registered, I want to call testLogin with the test user name and pw.
    testLogin(newUserName,newUserPassword)
  
    browser.close()
  </code></pre>