title: Cannot invoke method propertyMissing() in Groovy
body: <p>I am getting <code>Cannot invoke method propertyMissing()</code> error while trying to take screenshots in Geb.</p>
  
  <p>Following are the classes</p>
  
  <h2>MyLoginPage.groovy</h2>
  
  <pre><code>package geb.pages
  
  import geb.Page
  
  class MyLoginPage extends Page {
      static url = "https://JSPNet.com/entry"
      static at = { title == "My Login" }
  
  ....
  signIn { $("#btnEnter span")}
  
      def getScreenshots(){
  
          File scrFile = ((TakesScreenshot)DriverInstance).getScreenshotAs(OutputType.FILE)  ***** Error line ****
          FileUtils.copyFile(scrFile, new File("D:\\tmp\\screenshot.png"))
      }
  }
  </code></pre>
  
  <p>I am getting this error in the above class in relating to <code>DriverInstance</code> </p>
  
  <h2>GebConfig.groovy</h2>
  
  <pre><code>import org.openqa.selenium.chrome.ChromeDriver
  import org.openqa.selenium.firefox.FirefoxDriver
  
  
  driver = {
      System.setProperty("webdriver.chrome.driver", "D:\\MyFolder\\selenium-2.32.0\\chromedriver.exe")
      def newdriver = new ChromeDriver()
      DriverInstance = newdriver
      return newdriver
  }
  
  environments {
      chrome { driver = { new ChromeDriver() } }
      firefox {driver = { new FirefoxDriver() }}
  }
  
  waiting {timeout = 5}
  </code></pre>
  
  <h2>MyHomePage.groovy</h2>
  
  <pre><code>And(~'^hit the Login button$') { -&gt;
  
       page.signIn.click()
  
      MyLoginPage = new MyLoginPage()
      MyLoginPage.getScreenshots()
  
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>java.lang.NullPointerException: Cannot invoke method propertyMissing() on null object
                  at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
                  at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
                  at 
  
  org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
   at geb.pages.MyLoginPage.getScreenshots(MyLoginPage.groovy:70)
                  at geb.pages.MyLoginPage$getScreenshots.call(Unknown Source)
  </code></pre>