Selenium IDE

简介

Selenium IDE是Firefox浏览器的一个插件,依附于Firefox浏览器。Selenium IDE中的录制功能,可以详细的记录下你对Firefox浏览器的操作,并可实现你在浏览器中的操作回放。记录的测试脚本可以导出C#,Java,Ruby或Python等编程语言。

Selenium IDE 安装

安装Firefox浏览器,以下是我的Firefox浏览器版本: 

Selenium IDE_第1张图片

Firefox浏览器版本查看路径:

Selenium IDE_第2张图片

2.进入Firefox浏览器-附加组件页面,搜索Selenium IDE,点击进入并添加,成功添加后,重启浏览器。

Selenium IDE_第3张图片
Selenium IDE_第4张图片

成功添加后,浏览器右上方会显示“SE”标志,说明Selenium IDE组件添加成功,点击则可进入录制界面。

Selenium IDE_第5张图片

创建一个项目并给项目名:

Selenium IDE_第6张图片
Selenium IDE_第7张图片

Selenium IDE 界面说明

Selenium IDE_第8张图片

1.文件:打开和保存测试案例和测试案例集。

2.录制:点击之后,开始记录你对浏览器的操作,录制完再点击一下就停止录制。

3.运行所有:运行一个测试案例集中的所有案例。

4.运行:运行当前选定的测试案例。

5.暂停/恢复:暂停和恢复测试案例执行。

6.速度控制:控制案例的运行速度。

7.填写被测网站的地址。

8.案例集列表。

9.测试脚本:用表格形式展现命令、目标及值。

10.当前选中命令对应参数,可修改。

11.查看脚本运行通过/失败的个数。

12.运行日志:当你运行测试时,运行的每一步信息将会显示在Log。

以上截图说明参考原文(https://www.cnblogs.com/lengjf/p/8855401.html)

脚本录制

附上一段在Selenium IDE中录制的打开Firefox浏览器,并打开百度网页,实现搜索之后导出的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 vars;

      JavascriptExecutor js;

      @Before

      public void setUp() {

        driver = new FirefoxDriver();

        js = (JavascriptExecutor) driver;

        vars = new HashMap();

      }

      @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();

      }

    }

```

你可能感兴趣的:(Selenium IDE)