Пример #1
0
 /**
  * @param browser
  * @param url
  */
 public void initializeSelenium(String browser, String url) throws SAFSException {
   String id = getUniqueDriverID();
   try {
     WDLibrary.startBrowser(browser, url, id, BROWSER_TIMEOUT, USE_REMOTE, BROWSER_PARMS);
   } catch (Throwable th) {
     String thmsg = "WDSPC initial session start() error: " + th.getMessage();
     if (USE_REMOTE) {
       Log.info("WDSPC attempting to (re)start RemoteServer.");
       // if(WebDriverGUIUtilities.startRemoteServer()){
       if (WebDriverGUIUtilities.startRemoteServer(
           Runner.driver().iDriver().getProjectRootDir())) {
         try {
           WDLibrary.startBrowser(browser, url, id, BROWSER_TIMEOUT, USE_REMOTE, BROWSER_PARMS);
         } catch (Throwable th2) {
           thmsg = "WDSPC second session start() error:" + th2.getMessage();
           System.err.println(thmsg);
           Log.error(thmsg);
           throw new SAFSException(thmsg);
         }
       }
     } else {
       System.err.println(thmsg);
       Log.error(thmsg);
       throw new SAFSException(thmsg);
     }
   }
   Log.debug("Initialized browser: " + browser + " with ID: " + id);
   selenium = WDLibrary.getBrowserWithID(id);
   spcGUI.updateWindows(getWindows());
 }
Пример #2
0
 /* (non-Javadoc)
  * CANAGL -- this seems to be called prior to EVERY single Step in the script.
  * So only initialize IF we don't already have one.
  * @see com.sebuilder.interpreter.TestRun#initRemoteWebDriver()
  */
 @Override
 public void initRemoteWebDriver() {
   getLog().info("WDTestRun.initRemoteWebDriver invoked.");
   if (getDriver() != null) {
     getLog().info("WDTestRun.initRemoteWebDriver detected session already exists...");
     return;
   }
   int timeout = 30; // TODO get from parameters in this object!
   String browserID = "sebuilder_run" + System.currentTimeMillis();
   try {
     WDLibrary.startBrowser(null, null, browserID, timeout, true);
   } catch (Throwable th) {
     try {
       WebDriverGUIUtilities.launchSeleniumServers();
       try {
         WDLibrary.startBrowser(null, null, browserID, timeout, true);
         getLog().info("WDTestRun.initRemoteWebDriver successful starting browser session.");
       } catch (Throwable th2) {
         getLog()
             .debug("WDTestRun.initRemoteWebDriver failed to start a new WebDriver session:", th2);
       }
     } catch (SeleniumPlusException e) {
       getLog()
           .info(
               "WDTestRun.initRemoteWebDriver detected the expected RemoteServer is not running and cannot be started: "
                   + StringUtils.debugmsg(e));
     }
   }
 }
Пример #3
0
 /**
  * Perform the normal cleanup done at the end of script execution. Essentially, calls hasNext()
  * with stepIndex indicating all steps have been executed.
  */
 public void cleanup() {
   getLog().debug("WDTestRun.cleanup invoked after step " + (stepIndex + 1));
   stepIndex = getScript().steps.size();
   if (!hasNext() && (getDriver() != null) && (getScript().closeDriver)) {
     getLog().debug("WDTestRun.cleanup closing RemoteWebDriver.");
     try {
       WDLibrary.closeBrowser();
     } catch (Exception x) {
       getLog().debug("WDTestRun.cleanup error closing RemoteWebDriver: " + x.getMessage());
     }
   }
 }
Пример #4
0
 /**
  * Retrieve the "title" of each available browser "window" controlled by a WebDriver we have
  * launched.
  *
  * @return
  */
 public String[] getWindows() {
   Log.info("WDSPC getWindows blocked by runningGetAllElements.");
   while (runningGetAllElements) ;
   Log.info("WDSPC getWindows now proceeding...");
   runningWindowChecker = true;
   String[] titles = new String[0];
   try {
     titles = WDLibrary.getAllWindowTitles();
   } catch (Exception x) {
     Log.debug("WDSPC getWindows Exception:", x);
   }
   runningWindowChecker = false;
   return titles;
 }
Пример #5
0
 /* (non-Javadoc)
  * @see com.sebuilder.interpreter.TestRun#getDriver()
  */
 @Override
 public RemoteWebDriver getDriver() {
   getLog().info("WDTestRun.getDriver() invoked.");
   try {
     WebDriver webDriver = WDLibrary.getWebDriver();
     if (webDriver == null) {
       getLog().debug("WDTestRun.getDriver() is null.");
     } else {
       return (RemoteWebDriver) webDriver;
     }
   } catch (Exception x) {
     getLog().debug("WDTestRun.getDriver() " + x.getMessage());
   }
   return null;
 }
Пример #6
0
 public BufferedImage getCurrentPreview() {
   String imagepath = null;
   // let UI settle
   try {
     Thread.sleep(700);
   } catch (Exception x) {
   }
   try {
     imagepath = File.createTempFile("WDSPCBrowser", "png").getAbsolutePath();
     WDLibrary.captureScreen(imagepath);
     ii = ImageIO.read(new File(imagepath));
   } catch (Exception x) {
     Log.debug(
         "WDSPC.getAllElements getScreenshot "
             + x.getClass().getSimpleName()
             + ", "
             + x.getMessage());
   }
   return ii;
 }