当前位置: 首页>>代码示例>>Java>>正文


Java TemporaryFilesystem类代码示例

本文整理汇总了Java中org.openqa.selenium.io.TemporaryFilesystem的典型用法代码示例。如果您正苦于以下问题:Java TemporaryFilesystem类的具体用法?Java TemporaryFilesystem怎么用?Java TemporaryFilesystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TemporaryFilesystem类属于org.openqa.selenium.io包,在下文中一共展示了TemporaryFilesystem类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHtmlPage

import org.openqa.selenium.io.TemporaryFilesystem; //导入依赖的package包/类
/**
 * Function for obtaining the HTML BODY using the selected
 * {@link org.openqa.selenium.WebDriver}.
 * There are a number of configuration properties within
 * <code>nutch-site.xml</code> which determine whether to
 * take screenshots of the rendered pages and persist them
 * as timestamped .png's into HDFS.
 * @param url the URL to fetch and render
 * @param conf the {@link org.apache.hadoop.conf.Configuration}
 * @return the rendered inner HTML page
 */
public static String getHtmlPage(String url, Configuration conf) {
  WebDriver driver = getDriverForPage(url, conf);

  try {
    if (conf.getBoolean("selenium.take.screenshot", false)) {
      takeScreenshot(driver, conf);
    }

    String innerHtml = driver.findElement(By.tagName("body")).getAttribute("innerHTML");
    return innerHtml;

    // I'm sure this catch statement is a code smell ; borrowing it from lib-htmlunit
  } catch (Exception e) {
    TemporaryFilesystem.getDefaultTmpFS().deleteTemporaryFiles();
    throw new RuntimeException(e);
  } finally {
    cleanUpDriver(driver);
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:31,代码来源:HttpWebClient.java

示例2: DefaultSession

import org.openqa.selenium.io.TemporaryFilesystem; //导入依赖的package包/类
private DefaultSession(final DriverFactory factory, TemporaryFilesystem tempFs,
                       SessionId sessionId, final Capabilities capabilities) throws Exception {
  this.knownElements = new KnownElements();
  this.sessionId = sessionId;
  this.tempFs = tempFs;
  final BrowserCreator browserCreator = new BrowserCreator(factory, capabilities);
  final FutureTask<EventFiringWebDriver> webDriverFutureTask =
      new FutureTask<EventFiringWebDriver>(browserCreator);
  executor = new ThreadPoolExecutor(1, 1,
                                    600L, TimeUnit.SECONDS,
                                    new LinkedBlockingQueue<Runnable>());

  // Ensure that the browser is created on the single thread.
  EventFiringWebDriver initialDriver = execute(webDriverFutureTask);

  if (!isQuietModeEnabled(browserCreator, capabilities)) {
    // Memo to self; this is not a constructor escape of "this" - probably ;)
    initialDriver.register(new SnapshotScreenListener(this));
  }

  this.driver = initialDriver;
  this.capabilities = browserCreator.getCapabilityDescription();
  updateLastAccessTime();
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:25,代码来源:DefaultSession.java

示例3: cleanUpDriver

import org.openqa.selenium.io.TemporaryFilesystem; //导入依赖的package包/类
public static void cleanUpDriver(WebDriver driver) {
    if (driver != null) {
        try {
            driver.quit();
            TemporaryFilesystem.getDefaultTmpFS().deleteTemporaryFiles();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:11,代码来源:HttpWebClient.java

示例4: call

import org.openqa.selenium.io.TemporaryFilesystem; //导入依赖的package包/类
@Override
public String call() throws Exception {
  TemporaryFilesystem tempfs = getSession().getTemporaryFileSystem();
  File tempDir = tempfs.createTempDir("upload", "file");

  new Zip().unzip(file, tempDir);
  // Select the first file
  File[] allFiles = tempDir.listFiles();
  if (allFiles == null || allFiles.length != 1) {
    throw new WebDriverException("Expected there to be only 1 file. There were: " +
        allFiles.length);
  }

  return allFiles[0].getAbsolutePath();
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:16,代码来源:UploadFile.java

示例5: createSession

import org.openqa.selenium.io.TemporaryFilesystem; //导入依赖的package包/类
public static Session createSession(DriverFactory factory,
                                    SessionId sessionId, Capabilities capabilities)
    throws Exception {
  File tmpDir = new File(System.getProperty("java.io.tmpdir"), sessionId.toString());
  if (!tmpDir.mkdir()) {
    throw new WebDriverException("Cannot create temp directory: " + tmpDir);
  }
  TemporaryFilesystem tempFs = TemporaryFilesystem.getTmpFsBasedOn(tmpDir);

  return new DefaultSession(factory, tempFs, sessionId, capabilities);
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:12,代码来源:DefaultSession.java

示例6: getTemporaryFileSystem

import org.openqa.selenium.io.TemporaryFilesystem; //导入依赖的package包/类
public TemporaryFilesystem getTemporaryFileSystem() {
  return tempFs;
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:4,代码来源:DefaultSession.java

示例7: getTemporaryFileSystem

import org.openqa.selenium.io.TemporaryFilesystem; //导入依赖的package包/类
TemporaryFilesystem getTemporaryFileSystem(); 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:2,代码来源:Session.java


注:本文中的org.openqa.selenium.io.TemporaryFilesystem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。