title: Python..Behave..Selenium..Page Objects - Set up browser in environment.py but cannot access in page objects modules
body: <p>My file structure is as follows</p>
  
  <pre><code>Tests/
  ├── BehaveTest1
  │   ├── BehaveTest1.feature
  │       └── environment.py
  │   └── steps 
  │       └── test_steps.py
  ├── BehaveTest2
  │   ├── BehaveTest2.feature
  │       └── environment.py
  │   └── steps
  │       └── test_steps.py
  ├── common.py
  ├── __init__.py
  </code></pre>
  
  <p>I have set up the Chrome browser in <code>environment.py</code></p>
  
  <pre><code>from selenium import webdriver
  
  def before_feature(context, feature):
      print("Before feature\n")
      context.browser = webdriver.Chrome()
  </code></pre>
  
  <p>In a <code>base_model.py</code> I set up the base class for the Page Objects</p>
  
  <pre><code>class BaseModel:
      def __init__(self, browser):
          self.browser = browser
  </code></pre>
  
  <p>The first Page Object is <code>home_model.py</code></p>
  
  <pre><code>from selenium.common.exceptions import NoSuchElementException
  from .base_model import *
  
  class HomeModel(BaseModel):
      def __init__(self, context):
          BaseModel.__init__(self, context.browser)
  
      def cookie_notification(self):
          return "all4gn-cookie-policy-notification"
  
      def click_cookie_notification(self, context):
          context.browser.click_element('class', str(self.cookie_notification()))
  </code></pre>
  
  <p>When I run the tests, two browsers start up. Why is that?</p>
  
  <p>I want to make all my calls in the Page Objects, NOT in the step definitions. I just want to be able to call the Page Objects to in my step definitions.</p>
  
  <p>This means I need access to the <code>context</code> variable which controls the browser.</p>