【Selenium-WebDriver自学】Selenium-IDE不同的浏览器(八)
==========================================================================================================
写在前面:
Selenium IDE是FireFox的集成插件,目前而言,只能通过FireFox来录制脚本。
但是实际工作中,我们可能需要测试IE或者Chrome等其他浏览器,那么,可以通过其他途径来实现这个愿望。详细看下文。
==========================================================================================================
8. Selenium IDE- 不同的浏览器
Selenium IDE脚本只能对火狐的工具Firefox插件运行测试。
使用Selenium-IDE开发的测试可以对其他浏览器所保存为Selenium网络驱动器或硒的远程控制指令码执行。
脚本只能对火狐的工具Firefox插件运行测试。
使用Selenium-IDE开发的测试可以对其他浏览器所保存为Selenium网络驱动器或硒的远程控制指令码执行。
更多关于Selenium的webdriver和Selenium的远程控制,在后面的章节有详细讲解。
第1步:打开Selenium IDE任何已保存的测试
第2步:定位到“File”菜单,并选择“Export Test Suite As”,而选择将被列出。

第3步:现在让我们导出脚本“WebDriver”,并将其保存为同样的名称。
第4步:如下图所示,显示保存webdriver文件。
package com.example.tests; import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select; public class BaiduSearch1 {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer(); @BeforeClass(alwaysRun = true)
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://www.baidu.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
} @Test
public void testBaiduSearch1() throws Exception {
driver.get(baseUrl + "/");
// ERROR: Caught exception [unknown command []]
driver.findElement(By.id("kw")).clear();
driver.findElement(By.id("kw")).sendKeys("selenium");
driver.findElement(By.id("su")).click();
} @AfterClass(alwaysRun = true)
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;
}
}
}
以上为IDE导出的Java代码,可以通过其他途径来执行测试用例,运行到Chrome等浏览器上。
==========================================================================================================
学习小结:
1. 关于Selenium IDE的内容学习就告一段落了。
Selenium IDE执行的局限性和录制脚本/回放脚本等,包括自己去面试的时候提到的录制脚本,被别人嘲笑,所以决定学习更多的关于Selenium
方面的内容。
那么接下来,将学习Selenium/WebDriver的实际开发,相信会是另外一番学习体验。
==========================================================================================================
【Selenium-WebDriver自学】Selenium-IDE不同的浏览器(八)的更多相关文章
- selenium webdriver学习(二)————对浏览器的简单操作(转载JARVI)
selenium webdriver学习(二)————对浏览器的简单操作 博客分类: Selenium-webdriver selenium webdriver对浏览器的简单操作 打开一个测试浏览 ...
- Selenium WebDriver VS Selenium RC
WebDriver到底是什么? WebDriver是一个Web的自动化测试框架,它支持你执行你的测试用例在不同的浏览器上面,并不像Selenium一样只支持Firefox. WebDriv ...
- Selenium_用selenium webdriver实现selenium RC中的类似的方法
最近想总结一下学习selenium webdriver的情况,于是就想用selenium webdriver里面的方法来实现selenium RC中操作的一些方法.目前封装了一个ActionDrive ...
- Selenium WebDriver 之 PageObjects 模式 by Example
目录 1. 项目配置 2. 一个WebDriver简单例子 3. 使用Page Objects模式 4. 总结 5. Troubleshooting 6. 参考文档 本篇文章通过例子来阐述一下Sele ...
- 【自动化测试&爬虫系列】Selenium Webdriver
文章来源:公众号-智能化IT系统. 一. Selenium Webdriver技术介绍 1. 简介 selenium Webdriver是一套针对不同浏览器而开发的web应用自动化测试代码库.使用这套 ...
- 关于Selenium WebDriver的geckodriver
下载Selenium的最新版本地址:http://selenium-release.storage.googleapis.com/index.html 友情提示:如果一直下载不了,可能是浏览器与下载工 ...
- Selenium Webdriver概述(转)
Selenium Webdriver https://www.yiibai.com/selenium/selenium_overview.html# webdriver自动化俗称Selenium 2. ...
- 【零基础】Selenium:Webdriver图文入门教程java篇(附相关包下载)
一.selenium2.0简述 与一般的浏览器测试框架(爬虫框架)不同,Selenium2.0实际上由两个部分组成Selenium+webdriver,Selenium负责用户指令的解释(code), ...
- selenium webdriver学习(一)------------快速开始(转载JARVI)
selenium webdriver学习(一)------------快速开始 博客分类: Selenium-webdriver selenium webdriver 学习 selenium webd ...
- Selenium Tutorial (1) - Starting with Selenium WebDriver
Starting with Selenium WebDriver Selenium WebDriver - Introduction & Features How Selenium WebDr ...
随机推荐
- SmartGit 授权Non-Commerical
Window: %APPDATA%/syntevo/SmartGit/ 搜索settings.xml, 并且移除这个文件 重启
- 深入理解ASP.NET MVC(3)
系列目录 URL是如何通过路由表生成的(outbound) 通常我们被推荐在view设计时使用Html.ActionLink(…)产生链接,这样做的优势就是,url可以根据路由表生成.路由机制的另一个 ...
- NLP自然语言处理中的hanlp分词实例
本篇分享的依然是关于hanlp的分词使用,文章内容分享自 gladosAI 的博客,本篇文章中提出了一个问题,hanlp分词影响了实验判断结果.为何会如此,不妨一起学习一下 gladosAI 的这篇文 ...
- gcc与g++的一些关系
Gcc 简介Linux系统下的gcc(GNU C Compiler)是GNU推出的功能强大.性能优越的多平台编译器,是GNU的代表作品之一.Gcc是可以在多种硬体平台上编译出可执行程序的超级编译器,其 ...
- 在 vmware player中安装 ubuntu 17.10
目录 在 vmware 中安装 ubuntu 17.10 分区参考 vmware安装助手 第一步:更新 安装vmware tools 调整显示 第二步.输入法 五笔输入法 搜狗拼音输入法 ibus不能 ...
- SpringSecurity-ChannelProcessingFilter的作用
ChannelProcessingFilter决定的是web请求的通道,即http或https. 在springsecurity配置文件中添加这样一行 <intercept-url patter ...
- C++中函数的形参为数组时,实质形参是指针
C++中函数的形参如果为数组的话,那么进行实参传递时,实参实际上换转化成指针.参考下面的例子: #include<iostream> using namespace std; void f ...
- elasticsearch 口水篇(2)CRUD Sense
Sense 为了方便.直观的使用es的REST Api,我们可以使用sense.Sense是Chrome浏览器的一个插件,使用简单. 如图: Sense安装: https://chrome.googl ...
- AS3面试题 个人理解
现在as3面试 感觉就那几个题目来回考.有了题库,大家都看了 都答上来了 题目本身也就失去了考核的意义.而且题目本身也有很多偏的(不常用的)在考. 真正的面试官现在肯定也不会把笔试成绩当作标准.所谓: ...
- Scala传名参数(By-Name)
1.=> 在了解Scala的By-Name参数之前,先了解下“=>”在Scala中有几种用法: 1.对于值,“=>”相当于lambda表达式.如: scala> List(,, ...