web软件测试工具selenium完成测试脚本的录制

  1. 在火狐浏览器安装selenium IDE插件
    在这里插入图片描述

  2. 在搜索框搜索selenium并添加到Firefox
    在这里插入图片描述
    在这里插入图片描述

安装好后便会在右上角显示,点击即可打开。
在这里插入图片描述

3 Web软件功能界面测试
3.1.创建一个新的测试项目,并命名,然后点击OK
在这里插入图片描述

在这里插入图片描述

3.2 输入当测试的web应用URL地址,点击START RECORDING开始录制。我做的是超星学习通登录测试 。
在这里插入图片描述

点击START RECORDING 跳出以下网页
在这里插入图片描述

登录测试,输入错误的验证码
在这里插入图片描述

输入错误的密码
在这里插入图片描述

正确输入,成功登录系统
在这里插入图片描述

完成录制
在这里插入图片描述
在这里插入图片描述
将录制的脚本导出为你想要的语言,此处我选择的Java语言
在这里插入图片描述
在这里插入图片描述
选择保存位置及文件名,点击保存进行保存
在这里插入图片描述
4.录制的脚本代码为:

// 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 UntitledTest {
  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 untitled() {
    driver.get("http://passport2.chaoxing.com/login?fid=1867&refer=http://i.mooc.chaoxing.com");//测试网址
    driver.manage().window().setSize(new Dimension(1295, 735));
    driver.findElement(By.id("unameId")).click();
    driver.findElement(By.id("unameId")).sendKeys("18673910272");//账号
    driver.findElement(By.cssSelector("body")).click();
    driver.findElement(By.id("passwordId")).click();
    driver.findElement(By.id("passwordId")).sendKeys("11121112");//密码
    driver.findElement(By.cssSelector(".zlogin1")).click();
    driver.findElement(By.id("passwordId")).click();
    driver.findElement(By.id("passwordId")).sendKeys("111211");
    driver.findElement(By.cssSelector(".table_nvc > div")).click();
    driver.findElement(By.id("numcode")).click();
    driver.findElement(By.id("numcode")).sendKeys("8641");//验证码
    driver.findElement(By.cssSelector(".zl_btn_right")).click();
    {
      WebElement element = driver.findElement(By.cssSelector(".zl_btn_right"));
      Actions builder = new Actions(driver);
      builder.moveToElement(element).perform();
    }
    {
      WebElement element = driver.findElement(By.tagName("body"));
      Actions builder = new Actions(driver);
      builder.moveToElement(element, 0, 0).perform();
    }
    driver.findElement(By.id("passwordId")).click();
    driver.findElement(By.id("passwordId")).sendKeys("1232144");
    driver.findElement(By.id("numcode")).click();
    driver.findElement(By.id("numcode")).sendKeys("3717");
    driver.findElement(By.cssSelector(".zl_btn_right")).click();
    driver.findElement(By.id("passwordId")).click();
    driver.findElement(By.id("passwordId")).sendKeys("11121112");
    driver.findElement(By.cssSelector(".table_nvc > div")).click();
    driver.findElement(By.id("numcode")).click();
    driver.findElement(By.id("numcode")).sendKeys("5850");
    driver.findElement(By.cssSelector(".zl_btn_right")).click();
    driver.close();
    driver.findElement(By.id("unameId")).click();
    driver.findElement(By.id("unameId")).sendKeys("15660260444");
    driver.findElement(By.cssSelector("tr:nth-child(3) > .zl_name")).click();
    driver.findElement(By.id("passwordId")).click();
    driver.findElement(By.id("passwordId")).sendKeys("112324112345");
    driver.findElement(By.cssSelector(".table_nvc > div")).click();
    driver.findElement(By.id("numcode")).click();
    driver.findElement(By.id("numcode")).sendKeys("7324");
    driver.findElement(By.cssSelector(".zl_btn_right")).click();
    driver.findElement(By.id("passwordId")).click();
    driver.findElement(By.id("passwordId")).sendKeys("12412341235");
    driver.findElement(By.id("numcode")).click();
    driver.findElement(By.id("numcode")).click();
    driver.findElement(By.id("numcode")).sendKeys("0670");
    driver.findElement(By.cssSelector(".zl_btn_right")).click();
    driver.findElement(By.id("passwordId")).click();
    driver.findElement(By.id("passwordId")).sendKeys("11121112");
    driver.findElement(By.id("numcode")).click();
    driver.findElement(By.id("numcode")).sendKeys("1581");
    driver.findElement(By.cssSelector(".zl_btn_right")).click();
    driver.findElement(By.id("passwordId")).click();
    driver.findElement(By.id("passwordId")).sendKeys("11121112");
    driver.findElement(By.id("numcode")).click();
    driver.findElement(By.id("numcode")).sendKeys("5885");
    driver.findElement(By.cssSelector(".zl_btn_right")).click();
  }
}

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值