2012-03-06 97 views

回答

1

那麼你可以寫一個Groovy腳本到[您-web應用程序] /腳本/ _Events.groovy啓動和停止硒 (你將不得不安裝硒-RC插件之前有機會獲得seleniumConfig或硒服務器腳本)。

includeTargets << new File("$seleniumRcPluginDir/scripts/_SeleniumConfig.groovy") 
includeTargets << new File("$seleniumRcPluginDir/scripts/_SeleniumServer.groovy") 

eventTestPhaseStart = { phase -> 
    if(isAcceptance(phase)){ 
     startSeleniumServer() 
    } 
} 
eventTestPhaseEnd = { phase -> 
    if(isAcceptance(phase)){ 
     stopSeleniumServer() 
    } 
} 
isAcceptance = { phase-> 
    phase?.contains("acceptance"); 
} 
0

您需要首先啓動Selenium服務器,然後才能使用該客戶端實例。
因此,在調用defaultSelenium實例創建之前,可以使用RemoteControlConfiguration(Link to javadoc)對象啓動服務器,並將其用作SeleniumServer構造函數調用的參數,然後使用serverinstance.boot()調用引導服務器。

喜歡的東西

RemoteControlConfiguration rcc = new RemoteControlConfiguration() 
//set whatever values you want your rc to start with:port,logoutfile,profile etc. 

SeleniumServer ss = new SeleniumServer(rcc) 
ss.boot() 

確保您關閉它,當你用測試來完成。