title: How to handle popup window using selenium webdriver with Java
body: <p>Please help, I'm new in Selenium. I try to automate eCommerce website and I have problem to handle popup window. Here is the scenario:</p>
  
  <ol>
  <li>Go to <a href="http://www.lampsplus.com" rel="nofollow">http://www.lampsplus.com</a></li>
  <li>Click on Sale link in the header section.</li>
  <li>Click on the 1st item/product displayed on the page. (This will show the product page).</li>
  <li>On the product page, click on the red Add To Cart button. (This will add a product to cart and display a popup).</li>
  <li>On the popup, click the dark-grey Continue Shopping button. (This will close the popup.)</li>
  </ol>
  
  <p>I stuck on step 5 (Error message: Unable to locate element "Continue shopping button")
  Here is my code before step 5:</p>
  
  <pre><code> WebDriver d1 = new FirefoxDriver();
  d1.manage().window().maximize();
  d1.get("http://www.lampsplus.com");
  d1.findElement(By.name("hdr_sale")).click();
  d1.findElement(By.xpath(".//*[@id='sortResultContainer60238']/a[2]/span")).click();
  d1.findElement(By.id("pdAddToCart")).click(); //This is step 4
  //Here is suppose to be some code which handles the popup - my problem
  d1.findElement(By.id("aContinueShopping")).click();  //This is step 5
  </code></pre>
  
  <p>I'm aware about .getWindowHandle(); method. I tried several variations of it and none of them worked.
  Can anyone give me an idea how to handle it. Many thanks! I use Java.</p>
  
  <p>Note: I don't work for LampsPlus and not try to promote their products, this website was chosen for training purposes only.</p>