`
文章列表
Web 测试中我们经常会接触到Cookies,一个Cookies主要属性有”所在域、name、value、有效日期和路径",下面来讲一下怎么操作Cookies。 import java.util.Set; import org.openqa.selenium.Cookie; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class CookiesStudy { /** * @author gongjf ...
下面我们来看一下selenium webdriver是如何来处理select下拉框的,以http://passport.51.com/reg2.5p这个页面为例。这个页面中有4个下拉框,下面演示4种选中下拉框选项的方法。select处理比较简单,直接看代码吧:) import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; imp ...
alert、confirm、prompt这样的js对话框在selenium1.X时代也是难啃的骨头,常常要用autoit来帮助处理。 试用了一下selenium webdriver中处理这些对话框十分方便简洁。以下面html代码为例:   Dialogs.html <html> <head> <title>Alert</title> </head> <body> <input id = "alert" va ...
在selenium 1.X里面得到弹出窗口是一件比较麻烦的事,特别是新开窗口没有id、name的时候。当时还整理了处理了几种方法,详见:http://seleniumcn.cn/read.php?tid=791 。在selenium webdriver中得到新开窗口相对简单的多,它无关新开窗口的id、name等属性。以下面的html为例: test.html <html> <head><title>Test Popup Window</title></head> <body> ...
有时候我们在定位一个页面元素的时候发现一直定位不了,反复检查自己写的定位器没有任何问题,代码也没有任何问题。这时你就要看一下这个页面元素是否在一个iframe中,这可能就是找不到的原因之一。如果你在一个default content中查找一个在iframe中的元素,那肯定是找不到的。反之你在一个iframe中查找另一个iframe元素或default content中的元素,那必然也定位不到。 selenium webdriver中提供了进入一个iframe的方法: WebDriver org.openqa.selenium.WebDriver.TargetLocator.frame(S ...
selenium-webdriver提供了强大的元素定位方法,支持以下三种方法。 单个对象的定位方法 多个对象的定位方法 层级定位                         定位单个元素 在定位单个元素时,selenium-webdriver提示了如下一些方法 ...
在用selenium 1.X的时候常常会用到getEval()方法来执行一段js脚本来对页面进行处理,以处理一些遇到的问题。当然selenium webdriver也提供这样的一个方法:executeScript()   import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; public class SimpleExample { public static void main(String[] args) { WebDriver driver = ...
selenium webdriver对浏览器的简单操作   打开一个测试浏览器 对浏览器进行操作首先需要打开一个浏览器,接下来才能对浏览器进行操作。但要注意的是,因为Chrome Driver是Chromium 项目自己支持和维护的,所以你必需另外下载安装Chrome Driver,详细介绍查下他们的wiki 。   import java.io.File; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxBinary; import org.openqa.sel ...
selenium webdriver学习历程(一)------------快速开始 学习selenium已经两年了,从1.X到2.X,一直在关注它。中间由于工作原因中断了一段时间,但是一直无法割舍,最近又去官网看了一下,更新还挺快的。selenium1.X的时代将被取代,selenium-webdriver的大航海时代开始了。。。 安装selenium webdriver(eclipse+jdk+selenium webdriver2.20+firefox 10) 1、安装firefox,本人使用firefox10。确保firefox安装在默认环境下(不是的话会报错)。 2、安装jd ...
java2核心技术 I       因为所有在java.io中的类都是将相对路径名解释为起始于用户的当前工作目录,所以应该清楚当前的目录。 可以通过调用System.getProperty("user.dir") 来获得。 <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:aut ...
最近在学习webdriver,顺便把遇到的问题记在这里,以便日后查阅,并分享给遇到相同问题的人。   问题:运行seleniumhq.org网站上的例子。 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.support.ui.ExpectedCondition; ...
Global site tag (gtag.js) - Google Analytics