1.Selenium IDE

  在Chrome浏览器上登录谷歌应用商店可以安装Selenium IDE插件(3.0以上版本的Selenium IDE不支持录制的脚本导出,所以这里使用到的是应用商店上的另一款插件Katalon Recorder).

  进入IDE界面后,点击录制按钮,然后就可以登录相应的网站然后进行测试脚本的录制.

可以点击Play按钮回放之前录制的脚本,最后可以使用Export导出脚本为相应的代码。

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 WebTest {
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 = "https://www.katalon.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
} @Test
public void testWeb() throws Exception {
driver.get(baseUrl);
driver.findElement(By.id("username")).click();
driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys("username");
driver.findElement(By.id("password")).click();
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys("password");
driver.findElement(By.id("submitButton")).click();
assertEquals("url", driver.findElement(By.xpath("//p")).getText());
} @After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
} private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
} private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
} private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}

2.使用Selenium-java进行自动化测试

  下载相应的Selenium-java 的jar包,添加后可以运行之前导出的脚本文件,再下载POI读取存储在.xlsx文件中的需要测试的用户名密码地址对进行相应的自动化测试

  

使用Selenium IDE和webDriver进行自动化软件测试的更多相关文章

  1. [Training Video - 1] [Selenium Basics] [What is Selenium IDE,RC,Webdriver, TestNG, Junit And Ant]

    Selenium IDE (Only support in Firefox): - Record and Run - UI interface - User extensions - Conversi ...

  2. Selenium自动化测试之Selenium IDE

    简介 Selenium IDE 是实现Web自动化的一种便捷工具,本质上它是一种浏览器插件.该插件支持Chrome和Firefox浏览器,拥有录制.编写及回放操作等功能,能够快速实现Web的自动化测试 ...

  3. python+selenium自动化软件测试(第2章):WebDriver API

    2.1 操作元素基本方法 前言前面已经把环境搭建好了,从这篇开始,正式学习selenium的webdriver框架.我们平常说的 selenium自动化,其实它并不是类似于QTP之类的有GUI界面的可 ...

  4. selenium IDE & Remote Control & Webdriver

    一直忘记写selenium的开始学习的过程,今天趁五一,天气有雨,写下这文章 1.进入selnium官网,了解selenium1,2,grid的区别.下载c#相关的包(使用c#的人非常少) 2.使用I ...

  5. 2-2 selenium IDE自动化实战

    Selenium IDE 自动化实战 任务1: 自动在百度搜索"我要自学网" 然后在搜索结果页面点击进入自学网主页 任务2 实现自学网自动登录个人账号 Test2017 12345 ...

  6. 基于webdriver的jmeter性能测试-Selenium IDE

    前言: 由于某些项目使用了WebGL技术,需要高版本的Firefox和Chrome浏览器才能支持浏览,兼容性很弱,导致Loadrunner和jmeter(badboy)无法正常进行录制脚本.因此我们采 ...

  7. Web自动化Selenium2环境配置中Selenium IDE的安装

    下载的firefox32.0的版本,但是在附件组件中只有selenuim IDE button,本以为这个就是selenium IDE插件,自以为是的后果就是把自己坑了.并且像一些selenium I ...

  8. 【译】Selenium 2.0 WebDriver

    Selenium WebDriver   注意:我们正致力于完善帮助指南的每一个章节,虽然这个章节仍然存在需要完善的地方,不过我们坚信当前你看到的帮助信息是精确无误的,后续我们会提供更多的指导信息来完 ...

  9. 自动化测试辅助工具(Selenium IDE等)

    本随表目录 Selenium IDE安装和使用 FireBug安装和使用 FirePath安装和使用   Selenium IDE安装 方式一:打开Firefox-->添加组件-->搜索出 ...

随机推荐

  1. HDU 1024 Max Sum Plus Plus【DP】

    Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we ...

  2. js的eval代码快速解密

    有一段js代码内容如下: eval(function(E,I,A,D,J,K,L,H){function C(A)后面内容省略... 解密可以采用如下方法: 方法一: 打开谷歌浏览器,按F12,在Co ...

  3. Python SQLAlchemy多对多外键关联时表结构

    # 创建多对多表结构 from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.engine import cre ...

  4. ActiveReports报表控件 V13 正式发布,提供在线报表设计和自适应报表布局

    重磅消息, ActiveReports V13 正式发布!本次更新 ActiveReports 将给您带来全新的报表设计体验:提供在线报表设计器.提供响应式布局和屏幕尺寸自适应能力.提供全新的图表…… ...

  5. ES6解构过程添加一个默认值和赋值一个新的值

    const info = { name: 'xiaobe', } const { name: nickName = '未知' } = info; 其中nickName是解构过程中新声明的一个变量,并且 ...

  6. web优化及web安全攻防学习总结

    web优化 前端:(高性能网站建设进阶指南) 使用gzip压缩(节省服务器的 网络带宽) 减少http请求( 减少DNS请求所耗费的时间. 减少服务器压力. 减少http请求头) 使用cdn(用户可以 ...

  7. Xilinx Vivado的使用详细介绍(1):创建工程、编写代码、行为仿真

    Xilinx Vivado的使用详细介绍(1):创建工程.编写代码.行为仿真 Author:zhangxianhe 新建工程 打开Vivado软件,直接在欢迎界面点击Create New Projec ...

  8. vim编辑器-多行加注释与去注释

    在使用vim编辑器时,有时候需要对多行代码进行加注释或去注释,下面将介绍两种方法. 方法一:块选择模式 1. 插入注释 (1)首先按键盘上的ESC进入命令行模式 (2)再按Ctrl+V进入VISUAL ...

  9. java.lang.ClassNotFoundException: javax.servlet.SessionCookieConfig

    使用 MockMvc 模拟进行单元测试时出现以下的错误,网上看到的资料应该是说Spring4.0需要servlet3.0的支持? 在pom.xml更改servlet的版本依赖后即可

  10. oracle更改字符集为zhs16GBK

    PDBalter pluggable database PDBANBOB open; alter session set container=pdbanbob; ALTER SYSTEM ENABLE ...