groovy,geb(selenium),spockã«ããèªååãã¹ã ãã®ï¼ï¼- GebConfig.groovy
GebConfig.groovyã¯Gebã®ç°å¢è¨å®ãã¡ã¤ã«ã§ããã
åèï¼ http://www.gebish.org/manual/1.1/
Geb attempts to load a ConfigSlurper script named GebConfig.groovy from the default package (in other words, in the root of a directory that is on the classpath). If it is not found, Geb will try to load a ConfigSlurper class named GebConfig from the default package - this is useful if you run tests that use Geb from an IDE because you wonât have to specify GebConfig.groovy as a resource, Geb will simply fall back to the compiled version of the script. If both script and class are not found Geb will continue using all defaults.
GebConfig.grooby
import org.openqa.selenium.chrome.ChromeDriver import org.openqa.selenium.firefox.FirefoxDriver import geb.Browser /*********/ /** URL **/ /*********/ // setBaseUrl(def baseUrl) baseUrl = "http://localhost:8080" /************/ /** Driver **/ /************/ // setDriver(WebDriver driver) driver = { def driver = new FirefoxDriver() driver.javascriptEnabled = true driver } // ç°å¢å¤æ° environments { chrome { driver = { new ChromeDriver() } } firefox { driver = { new FirefoxDriver()} } } // sample : ãã¹ããã©ã¦ã¶åãæ¿ã // mvn -Dgeb.env=chrome test // or // mvn -Dgeb.env=firefox test /*************/ /** Waiting **/ /*************/ // setDefaultWaitTimeout(Double defaultWaitTimeout) // setDefaultWaitRetryInterval(Double defaultWaitRetryInterval) atCheckWaiting = true; // waitå¤ãããã©ã«ãtrueã«ãªã waiting { timeout = 5 retryInterval = 0.1 } // setWaitPreset(String name, Double presetTimeout, Double presetRetryInterval) waiting { presets { slow { timeout = 20 retryInterval = 2 } quick { timeout = 3 retryInterval = 0.5 } } } // Sample for waiting Browser.drive { waitFor("quick"){ 2 == 1 + 1 } } /**************/ /** ï¼ï¼ï¼ï¼ **/ /**************/ // setUnexpectedPages(Collection pages) unexpectedPages = [PageNotFoundPage, InternalServerErrorPage] /**************/ /** Report **/ /**************/ /** **/ // setReportsDir(File reportsDir) reportsDir = new File("target/geb-reports")// å ±åæ ¼ç´å reportOnTestFailureOnly = true // 失ææã®ã¿å ±å // PageSourceReporter // only HTML // ScreenshotAndPageSourceReporter // HTML And png // reporter = new CustomReporter() // ã«ã¹ã¿ã å ±ååºåãªãã¸ã§ã¯ã // API // void report(String label) // void reportGroup(String path) // cleanReportGroupDir()