code: @When("^I change active window$")
      public void seleniumChangeWindow() {
          String originalWindowHandle = commonspec.getDriver().getWindowHandle();
          Set<String> windowHandles = commonspec.getDriver().getWindowHandles();
  
          for (String window : windowHandles) {
              if (!window.equals(originalWindowHandle)) {
                  commonspec.getDriver().switchTo().window(window);
              }
          }
  
      }
docs: Change current window to another opened window.