selenium 2.44安装测试教程(附全程免费资料软件包下载)
2016-08-31 20:46
513 查看
休息时间接触了一下selenium,这个用于动态网页技术的自动化实现有很强的功能,我写这篇文章的时候也是初学阶段,但是最后是要到外文网站找教程才可以让程序跑起来,国内的感觉说的不足以让我完美的安装,于是想写一篇教程方便希望学习web自动化技术的各位同学作为参考(本文提到的安装包都会在末尾链接给出免费下载)
因为我还没完全搞懂chrome的调试,所以只给出Firefox浏览器的调试
直入主题:
进入这个selenium官方下载网页
http://www.seleniumhq.org/download/
现在讲最基本的java开发,所以大家按照官网导航是应该在这里找自己的语言下载api
但是因为selenium3是测试版本,我用的是2.44版本
然后下载selenium-java-2.44.0.zip
2.44对应的是Firefox 33版本的浏览器,版本别错了。
浏览器后面也会提供下载
然后把selenium-java-2.44.0.zip解压后的所有jar包都导入eclipse(这个应该不用教了吧。。)
然后跑这一段程序
运行结果:
好了,说明最简单的开发端口已经正常运行了。
现在我们安装一下Firefox,安装到默认路径。
然后跑一段代码:
可以正常打开Firefox说明配置正常,可以开始学习selenium其他技术了。(完)
下载链接:
http://download.csdn.net/detail/charchunchiu/9618255
因为我还没完全搞懂chrome的调试,所以只给出Firefox浏览器的调试
直入主题:
进入这个selenium官方下载网页
http://www.seleniumhq.org/download/
现在讲最基本的java开发,所以大家按照官网导航是应该在这里找自己的语言下载api
但是因为selenium3是测试版本,我用的是2.44版本
然后下载selenium-java-2.44.0.zip
2.44对应的是Firefox 33版本的浏览器,版本别错了。
浏览器后面也会提供下载
然后把selenium-java-2.44.0.zip解压后的所有jar包都导入eclipse(这个应该不用教了吧。。)
然后跑这一段程序
package test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.htmlunit.HtmlUnitDriver; public class SeleniumConsoleExample { public static void main(String[] args) { // Create HTML Unit Driver - this is the build in Selenium client WebDriver driver = new HtmlUnitDriver(); // go to url driver.get("http://www.baidu.com"); //driver.get("http://www.pbc.gov.cn"); // Check the title of the page System.out.println("Page title is: " + driver.getTitle()); driver.quit(); } }
运行结果:
Page title is: 百度一下,你就知道
好了,说明最简单的开发端口已经正常运行了。
现在我们安装一下Firefox,安装到默认路径。
然后跑一段代码:
package test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class test2 { public static void main(String[] args) throws Exception { // create a Firefox Web Driver WebDriver driver = new FirefoxDriver(); // open the browser and go to JavaTutorial Network Website driver.get("https://javatutorial.net"); // find the search button on the page WebElement searchButton = driver.findElement(By .className("search-submit")); // create an action handler Actions actions = new Actions(driver); // use the action handler to move the cursor to given element actions.moveToElement(searchButton).perform(); // wait until the search field is presented on the webpage and create an // element WebElement searchField = (new WebDriverWait(driver, 10)) .until(ExpectedConditions.presenceOfElementLocated(By.name("s"))); // puts the text "java" into the search field searchField.sendKeys("java"); // submit the search (submit the form) searchField.submit(); // wait 5 seconds and close the browser Thread.sleep(5000); driver.quit(); } }
可以正常打开Firefox说明配置正常,可以开始学习selenium其他技术了。(完)
下载链接:
http://download.csdn.net/detail/charchunchiu/9618255
相关文章推荐
- Android开发教程与视频教程类专题资料免费下载整理合集
- JProfiler免费下载使用安装方法教程破解地址购买价格功能大全
- Altair FluxMotor 2018安装教程(附软件资源免费下载)
- 衣联网络-亿能测试 安全测试沙龙 PPT资料免费下载
- Python 3.6.3 官网 下载 安装 测试 入门教程 (windows)
- illustrator cc 2018精简版64位下载(附安装教程和资源免费下载)
- Cadence SPB OrCAD Allegro 17.2安装破解详细图文教程(附破解文件下载)----本人亲自测试
- Web Service测试工具SOAPSonar免费下载及使用教程
- 微信小程序开发资料、工具、教程、源码(全套免费下载)
- 《kali linux 渗透测试初级教程》免费下载
- 互联网中有哪些免费的防火墙软件下载 免费防火墙软件下载安装教程
- LAMP兄弟连原创Linux视频教程-第2讲Linux系统安装[免费下载]
- 《kali linux 渗透测试初级教程》全套视频与课件免费下载
- Discuz建站教程:本地安装discuz网站,使用selenium做自动化测试
- PHP源代码加密软件工具zend guard 使用教程及免费下载功能详解loader 安装破解
- 资料|python软件安装+10G的免费学习视频教程!!!
- nastran2018安装教程(附资源免费下载)
- Python 3.6.3 官网 下载 安装 测试 入门教程 (windows)
- 《kali linux 渗透测试初级教程》免费下载
- 万网免费主机wordpress快速建站教程-wordpress下载及安装