Selenium IDE 安裝
下域IDE http://docs.seleniumhq.org/download/previous.jsp
然后打開firefox ,加載本組件
基于FireFox的測試插件中,Selenium IDE是其中的佼佼者。
Selenium IDE是一個(gè)基于FireFox的Web測試開發(fā)環(huán)境,可以錄制、編輯和調(diào)試測試。Selenium IDE包含了Selenium Core,因此可以輕易地在瀏覽器中錄制和回放測試。
Selenium IDE不僅僅是一個(gè)測試錄制工具,而是一個(gè)IDE,可以錄制測試,也可以手工編輯測試,可設(shè)置斷點(diǎn)進(jìn)行調(diào)試,可把測試保存到HTML、Ruby、C#、Java等其他腳本格式,然后使用Selenium RC來實(shí)現(xiàn)并運(yùn)行更加靈活和強(qiáng)大的測試。
Selenium IDE下載地址:http://selenium-ide.openqa.org/download.jsp
下載后,在FireFox中打開插件文件selenium-ide-0.8.7.xpi進(jìn)行安裝,重新啟動(dòng)FireFox后,可選擇菜單“Tools | Selenium IDE”打開Selenium IDE的界面。
錄制測試腳本的過程可以用“傻瓜式”來形容,手工編輯腳本是通過選擇和插入Selenium命令(Command)的方式來實(shí)現(xiàn)的,結(jié)合其在線命令幫助(Reference)還是比較容易上手的。可直接在FireFox中運(yùn)行測試腳本,也可調(diào)出TestRunner界面來執(zhí)行測試腳本。
Selenium IDE目前僅支持FireFox瀏覽器,IE中類似的Web測試錄制工具目前找到一個(gè)“WatiN Test Recorder”,支持在IE中錄制WatiN的測試腳本。
Server安裝
下載server
下載地址:http://docs.seleniumhq.org/download/
啟動(dòng)server
D: seleniumselenium-2.19.0>java -jar selenium-server-standalone-2.19.0.jar
錄制腳本
打開firefox瀏覽器如下
啟動(dòng)IDE 通過firefox來錄制相關(guān)的腳本
解決java實(shí)現(xiàn)的問題
瀏覽器打開失敗
解決辦法
(1)打開java工程屬性加載Selenium的jar包,要求新的jar包應(yīng)該可以解決本問題
(2)建議使用webDriver方式來執(zhí)行腳本
發(fā)送tom郵件舉例
package com.example.tests;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class Tom {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://web.mail.tom.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}