我使用geb和spock作爲我的驗收測試框架。一切都很順利,只是有一些測試存在問題,當它重定向到另一個網站時,系統會提示輸入用戶名和密碼來訪問該網站。因爲這是一個瀏覽器提示,而不是我可以提交的表單,有沒有什麼方法可以在網站的瀏覽器配置文件中自動設置或者將其設置在驅動程序上?geb如何自動填充用戶名/密碼提示
我使用Firefox作爲瀏覽器類型進行測試。
編輯:這是我的build.gradle文件
apply plugin: 'eclipse'
apply plugin: 'groovy'
apply plugin: 'idea'
repositories {
mavenCentral()
}
task wrapper(type: Wrapper) {
gradleVersion = '1.3'
}
// The drivers we want to use
ext.drivers = ["firefox"]
dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.8.6'
def gebVersion = "0.7.2"
def seleniumVersion = "2.26.0"
// If using Spock, need to depend on geb-spock
testCompile "org.codehaus.geb:geb-spock:$gebVersion"
testCompile "org.spockframework:spock-core:0.6-groovy-1.8"
// Drivers
drivers.each { driver ->
testCompile "org.seleniumhq.selenium:selenium-$driver-driver:$seleniumVersion"
}
}
drivers.each { driver ->
task "${driver}Test"(type: Test) {
testReportDir = reporting.file("$name/tests")
testResultsDir = file("$buildDir/test-results/$name")
systemProperty "geb.build.reportsDir", reporting.file("$name/geb")
systemProperty "geb.env", driver
// If you wanted to set the baseUrl in your build…
// systemProperty "geb.build.baseUrl", "http://myapp.com"
}
}
task test(overwrite: true, dependsOn: drivers.collect { tasks["${it}Test"] })
謝謝erdi,我會試試看。我發現了一篇文章,提到您可以使用與配置文件一起安裝的AutoAuth插件。 請參閱:http://watirmelon.com/2012/06/27/automatic-firefox-authentication-when-using-selenium-webdriver-with-autoauth/ 雖然我不會使用Watir(因爲它是一個Ruby庫)我可以嘗試一些與spock安裝相同的東西,因爲它使用Selenium驅動程序。此外,我們現在只關注在單個瀏覽器(Firefox)中進行測試,因此此解決方案已足夠。 我會回到這裏解決我們用來解決這個問題的解決方案。 – 2013-02-19 08:33:28