
Selenium +Webdriver
文章平均质量分 50
繁华陌路
恩恩
展开
-
selenium2获取隐藏元素内容
第一种 先获取元素通过 属性获取WebElement webElemt= webElement.findElement(By.xpath(“//*[@class=’xxxxxx]/a”)); //在ie下使用innerText 在火狐下使用textContent String linktext = webElemt.getAttribute(“innerText”);第二种 通过js获取WebE转载 2016-10-17 15:53:17 · 4106 阅读 · 0 评论 -
Selenium3+Firefox+IntelliJ IDEA
Selenium-java:3.4 Firefox:54.0 geckodriver:V0.17 JDK:1.8 IDEA:2017.1原创 2017-07-10 14:21:42 · 609 阅读 · 0 评论 -
Selenium(Webdriver)显式等待封装
// 显示等待页面元素出现的封装方法,参数为页面元素的By对象 public static WebElement waitWebElement(WebDriver driver, final By by, int second) { WebElement waitElement = null; WebDriverWait wait = new WebDrive转载 2017-07-10 14:15:12 · 1718 阅读 · 0 评论 -
Selenium Webdriver常用JS操作
Selenium Webdriver常用JS操作转载 2016-10-26 11:33:15 · 7233 阅读 · 0 评论 -
Selenium2(WebDriver)中执行JavaScript代码
在用selenium编写web页面的自动化测试代码时,可能需要执行一些JavaScript代码,selenium本身就支持执行js,我们在代码中可以使用executeScript、executeAsyncScript这两个方法来执行JS。 executeScript是同步方法,用它执行js代码会阻塞主线程执行,直到JS代码执行完毕; executeAsyncScript方法是异步方法转载 2017-05-24 15:21:02 · 6962 阅读 · 0 评论 -
Selenium2(WebDriver):启动浏览器、设置profile&加载插件
本文主要记录下在使用selenium2/webdriver时启动各种浏览器的方法、以及如何加载插件、定制浏览器信息(设置profile)等。 一、启动firefox浏览器(不需要下载驱动,原生支持)1、firefox安装在默认路径下://启动默认安装路径下的ff public void StartFireFoxByDefault(){ System.out.println(转载 2017-05-23 11:28:48 · 916 阅读 · 0 评论 -
Selenium获取表格里所有单元格的文本
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.testng.annotations.Test; public class LocateTable { public WebDriver d转载 2017-03-27 11:05:06 · 10888 阅读 · 0 评论 -
selenium 定位不到元素的原因及解决办法
1.动态id定位不到元素for example: //WebElement xiexin_element = driver.findElement(By.id("_mail_component_82_82")); WebElement xiexin_element = driver.findElement(By.xpath("//span[contains(.,'写转载 2017-02-13 13:47:01 · 14232 阅读 · 0 评论 -
Webdriver配合Tesseract-OCR 自动识别简单的验证码
在进行自动化测试,遇到验证码的问题,一般有两种方式 : 1.找开发去掉验证码或者使用万能验证码 2.使用OCR自动识别 使用OCR自动化识别,一般识别率不是太高,处理一般简单验证码还是没问题 这里使用的是Tesseract-OCR,下载地址:https://github.com/A9T9/Free-Ocr-Windows-Desktop/releases 怎么使用呢? 进入安装后的目录:转载 2017-03-03 10:38:46 · 825 阅读 · 0 评论 -
selenium高效应对Web页面元素刷新
当我们在页面上进行selenium.type()或者selenium.click()操作的时候,往往需要需要等待一个元素的出现,对于一般的网页,当我们进入一个新页面的时候,往往会使用selenium.waitForPageToLoad(WAITTIME);对弹出窗口中的元素,往往写死要等待多少秒,其实可以使用如下更加通用高效的方法,自己写一个waitForElement()的方法: Java代码p转载 2017-02-13 13:49:22 · 4761 阅读 · 0 评论 -
Selenium Webdriver Xpath
Xpath是非常强大的元素查找方式,使用这种方法几乎可以定位到页面上的任意元素。转载 2016-09-22 10:14:10 · 471 阅读 · 0 评论 -
Selenium Webdriver处理复选框及获取表格指定单元格的内容
通过xpath定位处理List<WebElement> checks = driver.findElements(By.xpath("//input[@type='checkbox']"));System.out.println(checks.size()); //获取页面上复选框个数for(int i =0;i<checks.size();i++){ //勾选所有复选框 checks原创 2016-10-26 15:42:27 · 2621 阅读 · 0 评论 -
Selenium启动加载用户配置的浏览器(Chrome/Firefox)
加载chrome用户配置 ChromeOptions options = new ChromeOptions(); options.addArguments("user-data-dir=C:\\Users\\test\\AppData\\Local\\Google\\Chrome\\User Data\\Default"); WebDriever driver = new C原创 2017-07-10 14:26:40 · 7769 阅读 · 2 评论