LoggingResultsFormatter htmlFormatter =
newHtmlResultFormatter(loggingWriter, resultEncoding);
htmlFormatter.setScreenShotBaseUri(""); // this is for linkingto the screenshots
htmlFormatter.setAutomaticScreenshotPath(resultPath);
// wrapHttpCommandProcessor from remote-control
LoggingCommandProcessor myProcessor =
new LoggingCommandProcessor(newHttpCommandProcessor(your-configs), htmlFormatter);
selenium= new LoggingDefaultSelenium(myProcessor);
selenium.start();
}
@After
public void tearDown() {
selenium.stop();
try {
if(null != loggingWriter) {
loggingWriter.close();
}
} catch(IOException e) {
//do nothing
}
}
7. 運行成功以后在指定的目錄中生成相應(yīng)的reports
七、框架優(yōu)勢
1. 記錄測試的過程,所見即是所得,selenium的所有內(nèi)部程序都是用Javascipt編寫的,比較靈活;
2. 可以通過selenium IDE錄制腳本,腳本可以回放,可以作為junit編碼的雛形;
3. 支持多種操作系統(tǒng);
4. 支持多種編碼語言。JAVA,.NET, Perl,Python, Ruby
八、框架劣勢
1. selenium的錄制工具只能安裝在firefox瀏覽器上, 如果系統(tǒng)界面不被firefox支持,那要花費一定的時間去手寫case。 不過近聽說有一個工具叫360WebTester ,可以支持IE的錄制,而且是國產(chǎn)的評價還不錯,有時間我要研究一下。