title: Passing Selenium Webdriver in a parameter. Is it possible in Python?
body: <p>I'm new to Python.</p>
  
  <p>The aim of my script is to parse Web page with Selenium Webdriver. There are two subtasks. The first task I've made with no errors. But all script was without any function.</p>
  
  <p>Now I'm trying to solve the second task in a little bit complicated way. I want to use functions.</p>
  
  <p>The question is:</p>
  
  <p><strong>Could I pass an active Selenium Webdriver in a function parameter?</strong></p>
  
  <p>The second question is:</p>
  
  <p><strong>If the answer is YES - could the second function also pass an active Webdriver to another function?</strong></p>
  
  <p>So I think about activating a Webdriver and passing it into functions without closing a session.</p>
  
  <p>My code is:</p>
  
  <pre><code>for key, value in enumerate(headers):
      webdriver.DesiredCapabilities.PHANTOMJS[
          'phantomjs.page.customHeaders.{}'.format(key)] = value
  
  w = webdriver.PhantomJS()
  
  ps = q_yn('Perform new links parsing?', default='no')
  
  if ps:
      csv_l = get_clist(w)
  
  &lt;...&gt;
  
  def get_clist(w):
      w.get(url)
      wait_pageload(w, 0)
      src = w.page_source
      BeautifulSoup(src, "lxml")
      ... (etc)
  
  &lt;..&gt;
  
  def wait_pageload(w, pt):
      if pt == 0:
          element = WebDriverWait(w, 10).until(
              EC.presence_of_element_located((By.CLASS_NAME, "serg_search_result")))
      elif pt == 1:
          element = WebDriverWait(w, 10).until(
              EC.presence_of_element_located((By.ID, "ya_share")))
      else:
          raise ValueError("Page type: %s is unknown" % pt)
  </code></pre>
  
  <p>When I try to build and run this script I see an error:</p>
  
  <pre><code>File "fts-crawl2.py", line 108, in wait_pageload
  EC.presence_of_element_located((By.CLASS_NAME, "serg_s")))
    File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/support/
    wait.py", line 71, in until
    value = method(self._driver)
  
  selenium.common.exceptions.WebDriverException: Message: Error - Unable
  to load Atom 'find_element' from file ':/ghostdriver/./third_party/webdriver-
  atoms/find_element.js'
  </code></pre>