コード例 #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
 /**
  * Takes a screenshot and returns as a base64 encoded string.
  *
  * <p>Doesn't add to report directly.
  *
  * @return base64 encoded string of screenshot
  */
 public String takeScreenShot() {
   if (se.driver() == null) return null;
   WebDriver driver = se.driver();
   if (!(driver instanceof TakesScreenshot)) driver = (new Augmenter()).augment(driver);
   try {
     return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64);
   } catch (Exception e) {
     se.log().trace(e.getMessage());
     se.log().trace(e.getStackTrace().toString());
   }
   se.util().sleep(500);
   return null;
 }