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. @echo off 与echo off

    echo off 关闭其他命令的显示(但是不包括自身这条命令) @echo off 关闭所有命令的显示(@关闭其后命令的显示)

  2. what's cloud computing? IaaS

    Cloud computing has changed the ITC industry. Companies like Amazon, Google and Microsoft have built ...

  3. 二叉树建立,遍历和二叉排序树的判断【c++】

    // test.cpp : Defines the entry point for the console application. // #include "stdafx.h" ...

  4. Linux压缩和解压汇总

    各种后缀的压缩包压缩方法和解压方法 压缩包 压缩 解压 .tar.gz和.tgz tar -czf jpg.tar.gz *.jpg tar -xzvf filename -C path .tar.b ...

  5. [转]关于Android系统的”点九”

    李华明Himi原创,转载务必在明显处注明:转载自[黑米GameDev街区] 原文链接: http://www.himigame.com/android-game/321.html 前几天群成员讨论过关 ...

  6. CoreAnimation 之CAReplicatorLayer

    CAReplicatorLayer: 主要作用有以下两个: CAReplicatorLayer的目的是为了高效生成许多相似的图层,它会绘制一个或多个图层的子图层 并在每个复制体上应用不同的变换 使用C ...

  7. 删除安装的 cocoapods 的缓存方法

    清除 Cocoapods 本地缓存 特殊情况下,由于网络或者别的原因,通过 cocoapods 下载的文件可能会有问题.这时候可以删除 Cocoapods 的缓存(~/Library/Caches/C ...

  8. thinkphp 杂项(3.2.3)

    G('start');//时间描点start php代码.... G('end');//时间描点end echo G('start','end',4).'-----------'; 时间统计echo ...

  9. 【leetcode】Min Stack -- python版

    题目描述: Design a stack that supports push, pop, top, and retrieving the minimum element in constant ti ...

  10. fscanf使用

    函数名: fscanf 简述:C语言中基本的文件操作 功 能: 从一个流中执行格式化输入,fscanf遇到空格和换行时结束,注意空格时也结束.这与fgets有区别,fgets遇到空格不结束. 简单的说 ...