示例#1
0
文件: WDSPC.java 项目: SAFSDEV/Core
 /**
  * @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
文件: WDSPC.java 项目: SAFSDEV/Core
  public boolean highlight(SPCTreeNode node) {
    String dbgmsg = "WDSPC.highlight ";
    String xpath = node.xpath;
    String scriptCommand = null;
    boolean highlighted = true;

    // CANAGL attempt at setFocus()?
    try {
      selenium.manage().window().setPosition(selenium.manage().window().getPosition());
    } catch (NullPointerException ignore) {
      if (selenium == null) {
        Log.warn(dbgmsg + "did not find a non-null selenium WebDriver to focus!");
      } else {
        Log.warn(
            dbgmsg
                + "did not find a non-null WebDriver window() to manage() for get/set Position!");
      }
    }

    try {
      String rs = node.getRecognitionString();
      if (rs == null || rs.length() == 0) {
        Log.debug(dbgmsg + "did not find stored recognition string. Switching to XPATH.");
        rs = "XPATH=" + xpath;
      }
      utils.setWDTimeoutLock();
      utils.setWDTimeout(0);

      WebElement item = SearchObject.getObject(rs);
      if (item == null) {
        Log.debug(dbgmsg + "did not find the WebElement using recognition string: " + rs);
        return false;
      }
      highlighted = SearchObject.highlight(item);

    } catch (Exception e) {
      Log.warn(dbgmsg + e + getClass().getSimpleName() + ": " + e.getMessage());
      highlighted = false;
    } finally {
      utils.resetWDTimeout();
      utils.resetWDTimeoutLock();
    }

    return highlighted;
  }