title: don't understand the reason of NullPointerException in my case. Selenium Webdriver + Java
body: <p>I have test:   </p>
  
  <pre><code> @Test
   public void postStatusTest() {
   loginPage.logInFacebook("my-email", "my-password");
   facebookMainPage.checkNotifications();
   facebookMainPage.postStatus("Test");
   }
  </code></pre>
  
  <p>where:</p>
  
  <pre><code>  public FacebookMainPage checkNotifications(){
    if (driver.findElements(notificationsButton).size() &gt; 0) driver.findElement(notificationButton).click();
    return new FacebookMainPage(driver);
    }
  </code></pre>
  
  <p>and: </p>
  
  <pre><code> public FacebookMainPage postStatus(String statusText){
   driver.findElement(textField).click();
   driver.findElement(textField).sendKeys(statusText);
   driver.findElement(postButton).click();
   return new FacebookMainPage(driver);
   }
  </code></pre>
  
  <p>can you, please, explain why in my case both methods <code>checkNotifications</code> and <code>postStatus</code> return <code>NullPointerException</code>? I've read theory, but I hardly understand what in my case can be wrong.</p>