簡介
Selenium IDE是Firefox瀏覽器的一個插件炕吸,依附于Firefox瀏覽器蕉陋。Selenium IDE中的錄制功能蚤蔓,可以詳細(xì)的記錄下你對Firefox瀏覽器的操作哼御,并可實現(xiàn)你在瀏覽器中的操作回放改艇。記錄的測試腳本可以導(dǎo)出C#胖替,Java研儒,Ruby或Python等編程語言。
Selenium IDE 安裝
安裝Firefox瀏覽器独令,以下是我的Firefox瀏覽器版本:?
Firefox瀏覽器版本查看路徑:
2.進入Firefox瀏覽器-附加組件頁面端朵,搜索Selenium IDE,點擊進入并添加燃箭,成功添加后冲呢,重啟瀏覽器。
成功添加后招狸,瀏覽器右上方會顯示“SE”標(biāo)志敬拓,說明Selenium IDE組件添加成功,點擊則可進入錄制界面裙戏。
創(chuàng)建一個項目并給項目名:
Selenium IDE 界面說明
1.文件:打開和保存測試案例和測試案例集乘凸。
2.錄制:點擊之后,開始記錄你對瀏覽器的操作累榜,錄制完再點擊一下就停止錄制营勤。
3.運行所有:運行一個測試案例集中的所有案例。
4.運行:運行當(dāng)前選定的測試案例壹罚。
5.暫停/恢復(fù):暫停和恢復(fù)測試案例執(zhí)行葛作。
6.速度控制:控制案例的運行速度。
7.填寫被測網(wǎng)站的地址猖凛。
8.案例集列表进鸠。
9.測試腳本:用表格形式展現(xiàn)命令、目標(biāo)及值形病。
10.當(dāng)前選中命令對應(yīng)參數(shù),可修改霞幅。
11.查看腳本運行通過/失敗的個數(shù)漠吻。
12.運行日志:當(dāng)你運行測試時,運行的每一步信息將會顯示在Log司恳。
以上截圖說明參考原文(https://www.cnblogs.com/lengjf/p/8855401.html)
腳本錄制
附上一段在Selenium IDE中錄制的打開Firefox瀏覽器途乃,并打開百度網(wǎng)頁,實現(xiàn)搜索之后導(dǎo)出的java語言腳本:
```java
? ? // Generated by Selenium IDE
? ? import org.junit.Test;
? ? import org.junit.Before;
? ? import org.junit.After;
? ? import static org.junit.Assert.*;
? ? import static org.hamcrest.CoreMatchers.is;
? ? import static org.hamcrest.core.IsNot.not;
? ? import org.openqa.selenium.By;
? ? import org.openqa.selenium.WebDriver;
? ? import org.openqa.selenium.firefox.FirefoxDriver;
? ? import org.openqa.selenium.chrome.ChromeDriver;
? ? import org.openqa.selenium.remote.RemoteWebDriver;
? ? import org.openqa.selenium.remote.DesiredCapabilities;
? ? import org.openqa.selenium.Dimension;
? ? import org.openqa.selenium.WebElement;
? ? import org.openqa.selenium.interactions.Actions;
? ? import org.openqa.selenium.support.ui.ExpectedConditions;
? ? import org.openqa.selenium.support.ui.WebDriverWait;
? ? import org.openqa.selenium.JavascriptExecutor;
? ? import org.openqa.selenium.Alert;
? ? import org.openqa.selenium.Keys;
? ? import java.util.*;
? ? import java.net.MalformedURLException;
? ? import java.net.URL;
? ? public class Test {
? ? ? private WebDriver driver;
? ? ? private Map<String, Object> vars;
? ? ? JavascriptExecutor js;
? ? ? @Before
? ? ? public void setUp() {
? ? ? ? driver = new FirefoxDriver();
? ? ? ? js = (JavascriptExecutor) driver;
? ? ? ? vars = new HashMap<String, Object>();
? ? ? }
? ? ? @After
? ? ? public void tearDown() {
? ? ? ? driver.quit();
? ? ? }
? ? ? @Test
? ? ? public void () {
? ? ? ? driver.get("https://www.baidu.com/");
? ? ? ? driver.manage().window().setSize(new Dimension(744, 695));
? ? ? ? driver.findElement(By.id("kw")).sendKeys("Selenium");
? ? ? ? driver.findElement(By.id("su")).click();
? ? ? ? driver.close();
? ? ? }
? ? }
```