title: How to do this in selenium
body: <p>I'm new in Selenium and I need your help. I was trying to run a test for creating a new tab and put a new page. I was using a CSS selector, but it didn't work. The console shows me: <code>stale element reference: element is not attached to the page document</code>.</p>
  <p>Here is a piece of the code:</p>
  <pre><code>@FindBy (css=&quot;.list-group &gt; a[id=\&quot;itemc\&quot;]&quot;)
      private List&lt;WebElement&gt; categories;
      @FindBy (css=&quot;body&quot;)
      private WebElement googleBar;
      public void testClick() {
          contactLink.click();
      }   
      public void moveTab(String web){
          googleBar.sendKeys(Keys.CONTROL + &quot;t&quot;);
          for(WebElement category : categories) {
          driver.get(web);
          w.waitForElementToBeVisible(driver,contactLink, 2);
          category.click();
      
          }
      }
  </code></pre>
  <p>The test is here:</p>
  <pre><code>package tests;
  
  import org.testng.annotations.Test;
  
  import pages.BlazeBasePage;
  import testrunner.BaseTest;
  
  public class test3 extends BaseTest{
       @Test
       public void verify3() {
            getLogger().info(&quot;Starting Second test&quot;); 
            // we initialize the different methods and tags 
            BlazeBasePage basePage = new BlazeBasePage(driver);
            basePage.moveTab(&quot;https://demoblaze.com/&quot;);               
        }
  }
  </code></pre>