title: Finding and clicking on elements in a new page by Selenium
body: <p>The situation is as such - </p>
  
  <ul>
  <li>From "something/login.php" page, i am clicking on a button which takes me to the home page "something/dashboard.php"</li>
  <li>Trying to click on a element on the new page "something/dashboard.php" but unable to locate element. </li>
  <li>I have then checked the currenturl with </li>
  </ul>
  
  <p><code>String actualUrl = driver.getCurrentUrl();</code></p>
  
  <p>and i am getting "something/login.php" page which means the driver is in the previous page. How do i change my focus to the new page and find elements of it? </p>
  
  <p>Here is my code -  </p>
  
  <pre><code>public static void main(String[] args) throws InterruptedException {
  
      //Set chromedriver path
      System.setProperty("webdriver.chrome.driver", "E:\\Tools\\New folder\\chromedriver_win32\\chromedriver.exe");
  
  
      WebDriver driver = new ChromeDriver();
  
  
      String url =  "something";
      driver.get(url);
  
  driver.findElement(By.id("username")).sendKeys("something");
      driver.findElement(By.id("password-field")).sendKeys("something");
      driver.findElement(By.id("btn3")).click();
  
  for (String handle : driver.getWindowHandles()) {
  
          driver.switchTo().window(handle);}
  
      driver.findElement(By.xpath("//*[@id=\"accordion\"]/li[3]/a")).click();
  </code></pre>