2013-02-15 3 views
0

나는 수용 테스트 프레임 워크로 geob with spock을 사용하고 있습니다. 다른 웹 사이트로 리디렉션 될 때 사이트에 액세스하기위한 사용자 이름과 비밀번호를 입력하라는 메시지가 표시되는 몇 가지 테스트에서 문제가 있다는 것을 제외하면 모든 것이 잘됩니다. 이것은 제출할 수있는 양식이 아닌 브라우저 프롬프트이기 때문에 사이트의 브라우저 프로필에 자동으로 설정하거나 드라이버에 설정할 수있는 방법이 있습니까?Geb 사용자 이름/비밀번호를 자동으로 입력하는 방법

브라우저 유형으로 firefox를 테스트 중입니다.

편집 : 여기 thit가 작동하는지 2.25.0에 대한 changlog 그것이 아직 드라이버 구현이 아니라고 언급으로 내가 아무 생각이 내 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"] }) 

답변

0

나는 파이어 폭스의 브라우저 프로파일을 사용하여 자동으로 메시지를 입력 할 플러그인을 설치 결국이 문제를 해결하기 위해. 그런 다음 Geb 수락 테스트에서 자동으로 Firefox를 올바른 프로파일과 함께 사용하도록 설정합니다.

0

하지만 방법에있다 WebDriver를 사용하여 경고로 전환 한 다음 authenticateUsing(Credentials) 메서드를 사용하십시오. 당신의 스팍 사양에서

은 다음을 시도해 볼 수도 있습니다 :

driver.switchTo().alert().authenticateUsing(new UserAndPassword('user', 'pass')) 
+0

감사합니다. erdi, 시도해 보겠습니다. 프로파일과 함께 설치된 AutoAuth 플러그인을 사용할 수 있다고 언급 한 기사를 발견했습니다. 참조 : http://watirmelon.com/2012/06/27/automatic-firefox-authentication-when-using-selenium-webdriver-with-autoauth/ 내가 Watir을 사용하지는 않지만 Ruby 라이브러리) 아마도 Selenium 드라이버를 사용하는 것과 같은 방법으로 spock을 설치하는 것과 비슷한 것을 시도 할 수 있습니다. 또한 현재 단일 브라우저 (Firefox)에서 테스트하는 데만 관심이 있으므로이 솔루션이 적합합니다. 이 문제를 해결하는 데 사용한 솔루션이 무엇인지 다시 살펴 보겠습니다. –

관련 문제