Selenium webdriver Java 高级应用】的更多相关文章

对于这一段还蛮有感慨的,只想说,代码还是需要自己去敲的. 1. 改变用户代理 import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.Firefo…
Selenium Webdriver 学习: http://jarvi.iteye.com/category/203994 https://github.com/easonhan007/webdriver_guide Selenium WebDriver经验杂记:http://blog.csdn.net/ant_yan/article/details/8185899http://blog.csdn.net/aerchi/article/category/936247 1. Selenium We…
1. 获取元素文本 WebElement类的getText()方法返回元素的innerText属性.所以元素里如果有子节点一样也会被返回出来.如下所示 public class GetText { @Test public void testGetText(){ //启动driver,打开被测页面 System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); WebDriver driver =…
策略 语法 语法 描述 By id driver.findElement(By.id()) driver.findElements(By.id()) 通过id属性定位元素 By name driver.findElement(By.name()) driver.findElements(By.name()) 通过name属性定位元素 By class name driver.findElement(By.className()) driver.findElements(By.className(…
Selenium WebDriver提供了隐式等待来同步测试.当使用了隐式等待执行测试的时候,如果WebDriver没有在DOM中找到元素,将继续等待,超出设定时间后,抛出找不到元素异常 即,当元素没有立即出现的时候,隐式等待将等待一段时间后,再查找DOM.默认时间是0. 一旦设置了隐式等待,它将存在在整个webdriver对象实例的生命周期中,隐式等待会让一个正常响应的应用的测试变慢,会在寻找每个元素时进行等待,这样增加了整个测试执行的时间. 应该避免或减少使用隐式等待 //等待60s dri…
开发环境 JDK 下载地址: http://www.oracle.com/technetwork/java/javase/downloads/index.html Eclipse: 下载地址:http://www.eclipse.org/downloads/ Selenium jar包 (这里用的是:selenium-java-2.45.0.zip ,selenium-server-standalone-2.45.0.jar) 下载地址:http://code.google.com/p/sele…
下面这段实例实现了以下功能: 1. profile使用用户本地电脑上的 (selenium 3有问题.因为selenium 3把profile复制到一个temp文件夹里,但并不复制回去.所以每次打开仍是一个空的浏览器.问题待解决) 2. 取出多个跳出框的title和内容 3. 验证打开页面的title是否正确 4. 获取页面弹出框中的验证码 package com.qiujy.testweb_mvn; import java.io.File; import java.io.IOException…
V1.0版本:直接新建WebDriver使用 import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; public class IETest { public static void main(String[] args) { WebDriver wd = new InternetExplorerDriver(); wd.get("http://www.baidu.co…
问题: Cannot find firefox binary in PATH. Make sure firefox is installed. 原因:selenium找不到Firefox浏览器. 方法一:重新安装Firefox在默认路径下. 方法二:直接用System.setProperty方法设置webdriver.firefox.bin的值 import org.junit.After;import org.junit.Before;import org.junit.Test;import…
最早接触的selenium是 selenium IDE,当时是为了准备论文.为了用IDE还下载了Firefox浏览器.后来接触过两个项目都需要selenium,一个采用selenium webdirver+junit4 +java,另外一个是采用 robot+selenium2library .总体感觉就是开源.简单.使用范围广.是网页测试必备单品. 关于selenium的好的学习资料: 官方User Guide:  http://seleniumhq.org/docs/ 官方API:  htt…