All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.selenide.grid.DownloadFileFromGridToFolder Maven / Gradle / Ivy

The newest version!
package org.selenide.grid;

import com.codeborne.selenide.DownloadsFolder;
import com.codeborne.selenide.Driver;
import com.codeborne.selenide.files.FileFilter;
import com.codeborne.selenide.impl.Downloader;
import org.jspecify.annotations.Nullable;

import java.io.File;

public class DownloadFileFromGridToFolder extends com.codeborne.selenide.impl.DownloadFileToFolder {
  private final Downloader downloader;

  public DownloadFileFromGridToFolder() {
    this(new Downloader());
  }

  DownloadFileFromGridToFolder(Downloader downloader) {
    this.downloader = downloader;
  }

  @Nullable
  @Override
  protected DownloadsFolder getDownloadsFolder(Driver driver) {
    return driver.isLocalBrowser() ?
      super.getDownloadsFolder(driver) :
      new GridDownloadsFolder(driver);
  }

  @Override
  protected void waitWhileFilesAreBeingModified(Driver driver, DownloadsFolder folder, long timeout, long pollingInterval) {
    if (driver.isLocalBrowser()) {
      super.waitWhileFilesAreBeingModified(driver, folder, timeout, pollingInterval);
    }
    // In Selenium Grid, we don't know files' modification time :(
  }

  @Override
  protected void failFastIfNoChanges(Driver driver, DownloadsFolder folder, FileFilter filter,
                                     long start, long timeout, long incrementTimeout) {
    if (driver.isLocalBrowser()) {
      super.failFastIfNoChanges(driver, folder, filter, start, timeout, incrementTimeout);
    }
    // In Selenium Grid, we don't know files' modification time :(
  }

  @Override
  protected File archiveFile(Driver driver, File downloadedFile) {
    if (driver.isLocalBrowser()) {
      return super.archiveFile(driver, downloadedFile);
    }
    return GridDownloader.archiveFile(downloader, driver, downloadedFile);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy