title: How do I print using getText from a page object model with log4j?
body: <p>I am coding some automated tests using the Selenium Webdriver in Netbeans. I have a pretty simple test, and I am implementing page objects. My trouble is here:</p>
  
  <ul>
  <li><p>I <em>previously</em> had this code:</p>
  
  <pre><code>//Click the Timing Parts subcategory
  WebElement PartSubcategory = driver.findElement(By.xpath("//label[contains(.,'Timing Parts &amp; Camshafts')]"));
  PartSubcategory.click();
  logger.info("Found subcategory: "+PartSubcategory.getText());
  </code></pre></li>
  <li><p>And, after implementing page object model, it looks like this.</p></li>
  </ul>
  
  <p><strong>Page object:</strong></p>
  
  <pre><code>    public class findPartSubcategory {
      private static WebElement element = null;
  
      //Click the Timing Parts subcategory
      public static WebElement PartSubcategory(WebDriver driver)
              {
          element = driver.findElement(By.xpath("//label[contains(.,'Timing Parts &amp; Camshafts')]"));
          return element;
              }        
       }
  </code></pre>
  
  <p><strong>Test code:</strong></p>
  
  <pre><code>    //Click the Timing Parts subcategory
      findPartSubcategory.PartSubcategory(driver).click();
      logger.info("Found subcategory: "+findPartCategory.getText());
  </code></pre>
  
  <p>So, the compile error is in getText(), "Cannot find symbol method getText()". I am guessing it's because I am not printing out a properly declared variable, but a page object class.</p>
  
  <p>So how do I get to print what it found for that page object? Yes, I am using log4j ver. 1</p>
  
  <p>Thanks!</p>