title: How can I accept cookies on a particular site?
body: <p>When writing a basic search test for a job website in Selenium Java, I ma having problems when trying to accept the cookie warning displayed on the site.</p>
  
  <p>The site has 2 cookie notifications, a middle layer and top layer banner that sit on each other.</p>
  
  <p>I would be grateful for any suggestions (I'm new to Selenium Java!) that would allow me to get past this somewhat irritating (but minor) issue.</p>
  
  <p>This is the code I am using to no avail (both cookie banners remains in place):</p>
  
  <p>I have attempted the xpath approach detailed below</p>
  
  <pre><code>import java.util.Arrays;
  import java.util.Set;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.openqa.selenium.remote.DesiredCapabilities;
  import org.openqa.selenium.Cookie;
  import org.openqa.selenium.Keys;
  import java.util.concurrent.TimeUnit;
  </code></pre>
  
  <p>importnet.bytebuddy.agent.builder.AgentBuilder.RedefinitionStrategy.DiscoveryStrategy.Explicit;
  //These are being imported from the Selenium package supplied via Project Level Build Path>External Libraries</p>
  
  <pre><code>public class Demo4SeleniumTypeAndClickXPathExperis {
  
  public static void main(String[] args) {
  
  
  System.setProperty("webdriverchrome.driver", "C:\\chromedriver.exe");
  WebDriver driver=new ChromeDriver();
  
  
  driver.get("https://www.experis.co.uk/");//Browser URL
  
  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  </code></pre>
  
  <p>//here is the offending item that seems to achieve no result</p>
  
  <pre><code>driver.findElement(By.xpath("//button[@title='Accept Cookies']")).submit();
  
  
  driver.findElement(By.xpath("//*[@id=\"query\"]")).sendKeys("test or tester or qa");
  driver.findElement(By.xpath("//*[@id=\"search\"]/span/div/div[1]/input")).clear();
  driver.findElement(By.xpath("//*[@id=\"search\"]/span/div/div[1]/input")).sendKeys("Bristol");
  driver.findElement(By.xpath("//*[@id=\"search\"]/span/div/div[1]/input")).sendKeys(Keys.RETURN);
  driver.findElement(By.xpath("//*[@id=\"search\"]/span/div/div[1]/input")).submit();
  
  driver.findElement(By.xpath("//*[@id=\"search\"]/span/div/div[1]/input")).submit();     
      //driver.close();
  
  
  
  
  }
  
  private static Object navigate() {
      // TODO Auto-generated method stub
      return null;
  </code></pre>
  
  <p>I am expecting to be able to accept the cookie banners and clear them from the screen</p>