title: Selenium (Java) - How to click on a link and then test if window is open?
body: <p>I've worked one a project, in which I display a list of names and their corresponding hyperlinks, each hyperlink text is different, so it would look something like this,</p>
  
  <p><li> name 1   (<a href="http://somesite.com/name1" rel="nofollow">http://somesite.com/name1</a>)</li>
  <li> name 2   (<a href="http://somesite.com/name2" rel="nofollow">http://somesite.com/name2</a>)</li>
  <li> name 3   (<a href="http://somesite.com/name3" rel="nofollow">http://somesite.com/name3</a>)</li>
  <li> name 4   (<a href="http://somesite.com/name4" rel="nofollow">http://somesite.com/name4</a>)</li></p>
  
  <p>Using the following line of code, I am able to get the required element,</p>
  
  <pre><code>arg1 = "http://somesite.com/name3"
  WebElement urlElement = driver.findElement("//a[contains(text(), '" + arg1 + "')]");
  </code></pre>
  
  <p>With this, I do get the urlElement. Now when I click on the urlElement, </p>
  
  <pre><code>urlElement.click();
  </code></pre>
  
  <p>I was expecting it to open window, so that later down the link, I can call, </p>
  
  <pre><code>driver.switchTo().window("opened window title")
  </code></pre>
  
  <p>I was expecting this to work but for some reason it fails stating these is no window by that title. </p>