我正在使用playframework 2.3。
当测试在CI env(Travis)上运行时,是否有方便的方法在本地使用FirefoxDriver
和RemoteWebDriver
?
经过一番努力,我得到了一个辅助特征:
trait EnvAwareDriver {
def driver(): WebDriver = {
if (System.getenv("CI") == "true") {
WebDriverFactory(FIREFOX)
} else {
val caps = DesiredCapabilities.firefox()
caps.setCapability("platform", "Linux")
caps.setCapability("version", "32 .0")
caps.setCapability("tunnelIdentifier", System.getenv("TRAVIS_JOB_NUMBER"))
new RemoteWebDriver(new URL("…"), caps)
}
}
}
有更好的方法吗?
答案 0 :(得分:0)
最后,通过提取trait
trait EnvAwareDriver {
def localDrivers: Seq[String => WebDriver]
def remoteDrivers: Seq[String => WebDriver]
def drivers: Seq[String => WebDriver] = if (System.getenv("CI") != "true") localDrivers else remoteDrivers
}