Selenium Webdriver 学习

http://jarvi.iteye.com/category/203994

https://github.com/easonhan007/webdriver_guide

Selenium WebDriver经验杂记
http://blog.csdn.net/ant_yan/article/details/8185899
http://blog.csdn.net/aerchi/article/category/936247

1. Selenium Webdriver java 浏览器中前进,后退,刷新操作。

System.setProperty("webdriver.firefox.bin","D:/Mozilla Firefox/firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.google.com.hk");
driver.navigate().forward(); // 前进
driver.navigate().back(); // 后退
driver.navigate().refresh(); // 刷新

2. TestNG实例:

http://blog.csdn.net/yuxinlong2006/article/details/6765522

http://magustest.com/blog/automationtesting/webdriver-testng/

WebDriver+TestNG+ANT 实现多浏览器兼容性测试

http://www.51testing.com/?uid-375957-action-viewspace-itemid-817942

3. Webdriver 针对iframe中的元素定位

Selenium2在使用get()方法打开一个网页的时候,是不会继续加载里面的iframe中的内容的(这一点与Selenium有所区别)。那么,我们就需要人为的要求Selenium2对iframe中的内容进行加载。
例子一:
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@class='g-editor-iframe']"))); 
例子二:
driver.switchTo().frame(driver.findElement(By.id("baiduSpFrame")));

切换主页

用getWindowHandle()方法可以快速的进行切换回主页:String strMainHandler = driver.getWindowHandle();driver.switchTo().window(strMainHandler);关于iframe中 元素定位和xpath,cssSelector定位可参考:http://blog.csdn.net/dancedan/article/details/7406942

4. Webdriver中操作下拉列表

对下拉框进行操作时首先要定位到这个下拉框,new 一个Selcet对象,然后对它进行操作。

5. Webdriver 利用Actions类模拟鼠标和键盘的操作

6. webdriver 中 层级定位

参见:http://jarvi.iteye.com/blog/1448025

7. webdriver 执行js脚本

http://jarvi.iteye.com/blog/1447755

8. webdriver 等待页面加载完成

http://jarvi.iteye.com/blog/1453662

9. Webdriver 通过调用JavascriptExecutor 使对象隐藏对象出现,操作对象。

http://blog.sina.com.cn/s/blog_539a70d30101ajsg.html

10.Selenium中webdriver的quit()和close()区别

在关闭driver时用Driver.Quit();不要用Driver.Close();
1. webDriver.Close() - Close the browser window that the driver has focus of //关闭当前焦点所在的窗口
2. webDriver.Quit() - Calls dispose //调用dispose方法
3. webDriver.Dispose() Closes all browser windows and safely ends the session 关闭所有窗口,并且安全关闭session
参考:
 
 

Selenium Webdriver java 积累一的更多相关文章

  1. [selenium webdriver Java]常用api

    1. 获取元素文本 WebElement类的getText()方法返回元素的innerText属性.所以元素里如果有子节点一样也会被返回出来.如下所示 public class GetText { @ ...

  2. [selenium webdriver Java]元素定位——findElement/findElements

    策略 语法 语法 描述 By id driver.findElement(By.id()) driver.findElements(By.id()) 通过id属性定位元素 By name driver ...

  3. [selenium webdriver Java]隐式的等待同步

    Selenium WebDriver提供了隐式等待来同步测试.当使用了隐式等待执行测试的时候,如果WebDriver没有在DOM中找到元素,将继续等待,超出设定时间后,抛出找不到元素异常 即,当元素没 ...

  4. Selenium WebDriver java 简单实例

    开发环境 JDK 下载地址: http://www.oracle.com/technetwork/java/javase/downloads/index.html Eclipse: 下载地址:http ...

  5. Java 学习笔记 (二) Selenium WebDriver Java 弹出框

    下面这段实例实现了以下功能: 1. profile使用用户本地电脑上的 (selenium 3有问题.因为selenium 3把profile复制到一个temp文件夹里,但并不复制回去.所以每次打开仍 ...

  6. Selenium webdriver Java 操作IE浏览器

    V1.0版本:直接新建WebDriver使用 import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetE ...

  7. Selenium webdriver Java firefox 路径设置问题

    问题: Cannot find firefox binary in PATH. Make sure firefox is installed. 原因:selenium找不到Firefox浏览器. 方法 ...

  8. Selenium webdriver Java 高级应用

    对于这一段还蛮有感慨的,只想说,代码还是需要自己去敲的. 1. 改变用户代理 import org.junit.AfterClass; import org.junit.BeforeClass; im ...

  9. Selenium webdriver Java 开始

    最早接触的selenium是 selenium IDE,当时是为了准备论文.为了用IDE还下载了Firefox浏览器.后来接触过两个项目都需要selenium,一个采用selenium webdirv ...

随机推荐

  1. 记录一下两个比较常用的md5加密算法

    第一个,计算字符串的md5值 public static String getMD5(String s){ String newString = null; byte[] inputByteArray ...

  2. cookie 巩固

    设定cookie 过期时间: Cookie coke = new Cookie("name", "pattern"); coke.setMaxAge(60);/ ...

  3. 使用SQL语句对数据进行MD5加密

    如果数据库表User中有一列为passwd,存放的是md5加密的数据,如何更新新的数据. update user set passwd=md5("123321") where uN ...

  4. [Linux]系统调用理解(4)

    这是本专栏中进程相关的系统调用的最后一篇,用2个实例演示了以往学习的内容.其一是Mini Shell,仿常用的Bash而做,但对其作了大大简化:其二是一个Daemon程序,可以使读者一窥服务器编程的端 ...

  5. mysql时间段内查询

    今天 select * from 表名 where to_days(时间字段名) = to_days(now()); 昨天 SELECT * FROM 表名 WHERE TO_DAYS( NOW( ) ...

  6. October 17th 2016 Week 43rd Monday

    You only live once, but if you do it right, once is enough. 人生只有一次,但如果活对了,一次也就够了. Whether you do it ...

  7. 【leetcode】Simplify Path

    题目简述: Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/& ...

  8. Gamma校正与线性空间

    基础知识部分 为了方便理解,首先会对(Luminance)的相关概念做一个简单介绍.如果已经了解就跳到后面吧. 我们用Radiant energy(辐射能量)来描述光照的能量,单位是焦耳(J),因为光 ...

  9. npm-bluebird使用

    API 注意 时刻注意return; 使用Promise.promisify简化对test(val, function(err, result){})的处理; 尽量避免使用deferred objec ...

  10. jQuery插件(多级菜单)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...