public static void setTimeoutImplicit(WebDriver webDriver, String timeout) {
    WebDriver.Options options = webDriver.manage();

    WebDriver.Timeouts timeouts = options.timeouts();

    timeouts.implicitlyWait(GetterUtil.getInteger(timeout), TimeUnit.MILLISECONDS);
  }
  public BaseWebDriverImpl(String projectDirName, String browserURL, WebDriver webDriver) {

    super(webDriver);

    _projectDirName = projectDirName;

    if (OSDetector.isWindows()) {
      _dependenciesDirName = StringUtil.replace(_dependenciesDirName, "//", "\\");

      _outputDirName = StringUtil.replace(_outputDirName, "//", "\\");

      _projectDirName = StringUtil.replace(_projectDirName, "//", "\\");

      _sikuliImagesDirName = StringUtil.replace(_sikuliImagesDirName, "//", "\\");
      _sikuliImagesDirName = StringUtil.replace(_sikuliImagesDirName, "linux", "windows");
    }

    if (!TestPropsValues.MOBILE_DEVICE_ENABLED) {
      WebDriver.Options options = webDriver.manage();

      WebDriver.Window window = options.window();

      int x = 1065;
      int y = 1040;

      window.setSize(new Dimension(x, y));
    }

    webDriver.get(browserURL);
  }
  public static void setTimeoutImplicit(WebDriver webDriver, String timeout) {
    WebDriver.Options options = webDriver.manage();

    WebDriver.Timeouts timeouts = options.timeouts();

    if (!PropsValues.BROWSER_TYPE.equals("safari")) {
      timeouts.implicitlyWait(GetterUtil.getInteger(timeout), TimeUnit.MILLISECONDS);
    }
  }
  public static Point getWindowPoint(WebDriver webDriver) {
    WebElement bodyWebElement = getWebElement(webDriver, "//body");

    WrapsDriver wrapsDriver = (WrapsDriver) bodyWebElement;

    WebDriver wrappedWebDriver = wrapsDriver.getWrappedDriver();

    WebDriver.Options options = wrappedWebDriver.manage();

    WebDriver.Window window = options.window();

    return window.getPosition();
  }
Example #5
0
 public void setSession(Session session) {
   WebDriver.Options options = getDriver().manage();
   options.deleteAllCookies();
   if (session != null) {
     for (Cookie cookie : session.getCookies()) {
       options.addCookie(cookie);
     }
   }
   if (session != null && !StringUtils.isEmpty(session.getSecretToken())) {
     this.secretToken = session.getSecretToken();
   } else {
     recacheSecretToken();
   }
 }
Example #6
0
  public Logger(LiferaySelenium liferaySelenium) {
    _liferaySelenium = liferaySelenium;

    WebDriver.Options options = _webDriver.manage();

    WebDriver.Window window = options.window();

    window.setPosition(new Point(1000, 50));
    window.setSize(new Dimension(600, 700));

    JavascriptExecutor javascriptExecutor = (JavascriptExecutor) _webDriver;

    javascriptExecutor.executeScript("window.name = 'Log Window';");
  }
  @Override
  public void setWindowSize(String coordString) {
    WebElement bodyWebElement = getWebElement("//body");

    WrapsDriver wrapsDriver = (WrapsDriver) bodyWebElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    WebDriver.Options options = webDriver.manage();

    WebDriver.Window window = options.window();

    String[] screenResolution = StringUtil.split(coordString, ",");

    int x = GetterUtil.getInteger(screenResolution[0]);
    int y = GetterUtil.getInteger(screenResolution[1]);

    window.setSize(new Dimension(x, y));
  }
Example #8
0
  @Override
  public Page download(Request request, Task task) {
    checkInit();
    WebDriver webDriver;
    try {
      webDriver = webDriverPool.get();
    } catch (InterruptedException e) {
      logger.warn("interrupted", e);
      return null;
    }
    logger.info("downloading page " + request.getUrl());
    webDriver.get(request.getUrl());
    try {
      Thread.sleep(sleepTime);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    WebDriver.Options manage = webDriver.manage();
    Site site = task.getSite();
    if (site.getCookies() != null) {
      for (Map.Entry<String, String> cookieEntry : site.getCookies().entrySet()) {
        Cookie cookie = new Cookie(cookieEntry.getKey(), cookieEntry.getValue());
        manage.addCookie(cookie);
      }
    }

    /*
     * TODO You can add mouse event or other processes
     *
     * @author: [email protected]
     */

    WebElement webElement = webDriver.findElement(By.xpath("/html"));
    String content = webElement.getAttribute("outerHTML");
    Page page = new Page();
    page.setRawText(content);
    page.setHtml(new Html(UrlUtils.fixAllRelativeHrefs(content, request.getUrl())));
    page.setUrl(new PlainText(request.getUrl()));
    page.setRequest(request);
    webDriverPool.returnToPool(webDriver);
    return page;
  }
  public BaseWebDriverImpl(String projectDirName, String browserURL, WebDriver webDriver) {

    super(webDriver);

    String dependenciesDirName =
        "portal-web//test//functional//com//liferay//portalweb//" + "dependencies//";

    String outputDirName = TestPropsValues.OUTPUT_DIR_NAME;

    String sikuliImagesDirName = dependenciesDirName + "sikuli//linux//";

    if (OSDetector.isWindows()) {
      dependenciesDirName = StringUtil.replace(dependenciesDirName, "//", "\\");

      outputDirName = StringUtil.replace(outputDirName, "//", "\\");

      projectDirName = StringUtil.replace(projectDirName, "//", "\\");

      sikuliImagesDirName = StringUtil.replace(sikuliImagesDirName, "//", "\\");
      sikuliImagesDirName = StringUtil.replace(sikuliImagesDirName, "linux", "windows");
    }

    _dependenciesDirName = dependenciesDirName;
    _outputDirName = outputDirName;
    _projectDirName = projectDirName;
    _sikuliImagesDirName = sikuliImagesDirName;

    if (!TestPropsValues.MOBILE_DEVICE_ENABLED) {
      WebDriver.Options options = webDriver.manage();

      WebDriver.Window window = options.window();

      int x = 1280;
      int y = 1040;

      window.setSize(new Dimension(x, y));
    }

    webDriver.get(browserURL);
  }