me.saro.selenium.ChromeDriverManager.kt Maven / Gradle / Ivy
package me.saro.selenium
import me.saro.selenium.model.DownloadStrategy
import me.saro.selenium.model.PathManager
import me.saro.selenium.model.Platform
import me.saro.selenium.service.ChromeDriverPlus
import me.saro.selenium.service.ChromeManager
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import java.io.File
interface ChromeDriverManager {
fun openBackground(url: String, use: ChromeDriverPlus.() -> T): T =
openWith(url, setOf("--headless"), use)
fun openBackground(url: String, addOption: Set, use: ChromeDriverPlus.() -> T): T =
openWith(url, addOption + setOf("--headless"), use)
fun openWith(url: String, use: ChromeDriverPlus.() -> T): T =
openWith(url, setOf(), use)
fun openWith(url: String, addOption: Set, use: ChromeDriverPlus.() -> T): T
fun newChromeDriver(chromeOptions: ChromeOptions): ChromeDriver
companion object {
@JvmStatic
fun builder(manageChromePath: File): ChromeDriverBuilder =
ChromeDriverBuilder(manageChromePath)
@JvmStatic
fun download(manageChromePath: File, platform: Platform, downloadStrategy: DownloadStrategy) {
if (downloadStrategy == DownloadStrategy.THROW_IF_NO_VERSION) {
throw RuntimeException("download failed: downloadStrategy is THROW_IF_NO_VERSION")
}
ChromeManager.load(PathManager.create(manageChromePath, platform), downloadStrategy)
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy