title: automate the second window with selenium with java
body: <p>I have to automate a program, when logging in, a second window opens, in this the whole program opens. I'm trying to automate the second window, but it doesn't let me, I don't know how it can be done, since it allows me to close the window, but it doesn't let me click inside the window.</p>
  
  <pre><code>String driverPath = "C:\\\\geckodriver-master\\\\GeckoDriver.exe";
          System.setProperty("webdriver.gecko.driver", driverPath);
           WebDriver driver= new FirefoxDriver();
          driver.get("http://192.168.1.210/Panacea/LogOnForm.aspx");
  
          String currentWindow = driver.getWindowHandle();
          System.out.println("Current Window: "+currentWindow);
  
          driver.findElement(By.id("UserNameTextBox_I")).sendKeys("jtabaresg");;
          driver.findElement(By.id("PasswordTextBox_I")).sendKeys("Panacea1");;
          WebElement clickElement = driver.findElement(By.id("ImageButton1"));  
          clickElement.click();
  
          ArrayList&lt;String&gt; handle = new ArrayList&lt;String&gt;(driver.getWindowHandles());
          System.out.println("Handle list:"+ handle);
  
          for(String item: handle) {
              driver.switchTo().window(item);
              System.out.println("This is the page with title: "+driver.getTitle());
              //driver.switchTo().frame(2);
  
  
          }
  
         // driver.findElement(By.name("CLINICA EL PRADO ")).click();
         driver.findElement(By.name("CLINICA")).click();
  </code></pre>