コード例 #1
0
ファイル: Browser.java プロジェクト: srihariinnamuri/trunk
 /**
  * Closes the active Pop Up, assumes only 1 Pop Up is open
  *
  * @return
  */
 public boolean closePopUp() {
   try {
     se.log().logSeStep("Closing PopUp:");
     if (currentPopUp != null) {
       se.driver().switchTo().window(currentPopUp).close();
       se.driver().switchTo().window(prevWindowHandle);
       se.util().sleep(1000);
       currentPopUp = null;
       prevWindowHandle = null;
       return true;
     } else {
       String currentWindow = se.driver().getWindowHandle();
       Set<String> windows = se.driver().getWindowHandles();
       for (Iterator<String> iterator = windows.iterator(); iterator.hasNext(); ) {
         String string = (String) iterator.next();
         if (!currentWindow.equals(string)) {
           se.driver().switchTo().window(string).close();
           se.driver().switchTo().window(currentWindow);
           se.util().sleep(1000);
           return true;
         }
       }
     }
     return false;
   } catch (Exception e) {
     se.log().logSeStep("Un-handled Exception in closePopUp:");
     se.log().logSeStep(e.getMessage());
     return false;
   }
 }
コード例 #2
0
ファイル: Browser.java プロジェクト: srihariinnamuri/trunk
 /**
  * Returns if Popup is present and switches context to the popup window if present.
  *
  * @return true if popup is present, and switches test context to the popup.
  */
 public boolean isPopup() {
   try {
     se.log().logSeStep("Checking for PopUp:");
     String currentWindow = se.driver().getWindowHandle();
     Set<String> windows = se.driver().getWindowHandles();
     for (Iterator<String> iterator = windows.iterator(); iterator.hasNext(); ) {
       String string = (String) iterator.next();
       if (!currentWindow.equals(string)) {
         se.log().logSeStep("PopUp Found");
         currentPopUp = string;
         prevWindowHandle = currentWindow;
         se.driver().switchTo().window(currentPopUp);
         se.log().logSeStep("Switching Context to PopUp window: " + se.driver().getTitle());
         return true;
       }
     }
     return false;
   } catch (Exception e) {
     se.log().logSeStep("Un-handled Exception in isPopup:");
     se.log().logSeStep(e.getMessage());
     return false;
   }
 }