转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 问题:有一些元素,无论是通过id或是xpath等等,怎么都定位不到. 分析:这很可能是因为你要定位的元素被嵌套在了当前页面的一个iframe元素中,Selenium对iframe中的元素有特殊的定位规则,WebDriver不能够直接进行定位. 解决办法:我们要把这个iframe元素找出来,让WebDriver转移到这个iframe元素上,之后再让WebDriver对iframe中的元素进行定位.…
场景 在web 应用中经常会出现frame 嵌套的应用,假设页面上有A.B 两个frame,其中B 在A 内,那么定位B 中的内容则需要先到A,然后再到B.      switch_to_frame 方法可以把当前定位的主体切换了frame 里.怎么理解这句话呢?我们可以从frame的实质去理解.frame 中实际上是嵌入了另一个页面,而webdriver 每次只能在一个页面识别,因此才需要用switch_to.frame 方法去获取frame 中嵌入的页面,对那个页面里的元素进行定位.   …
以东方财富网登录页面为例: 在查找元素过程中,直接通过id或者xpath等找不到元素,查看页面源代码发现元素是属于iframe里,例如: <div class="wrap_login"> <iframe class="frame_login" src="https://exaccount.eastmoney.com/home/login?request=%7b%22agentPageUrl%22%3a%22https%3a%2f%2fpa…
在查找元素过程中,直接通过id或者xpath等找不到元素,查看页面源代码发现元素是属于iframe里,例如: <div class="wrap_login"> <iframe class="frame_login" src="https://exaccount.eastmoney.com/home/login?request=%7b%22agentPageUrl%22%3a%22https%3a%2f%2fpassport.eastmon…
以 jQuery UI 官方网站元素测试,地址:http://jqueryui.com/draggable/ 示例: package com.learningselenium.html5; import java.util.NoSuchElementException; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; import org.…
原文:http://www.cnblogs.com/tobecrazy/p/4570494.html 工作中使用到记录一下. 主要有: 上传 alter dialog prompt dialog confirm dialog select list radio box input box checkBox 测试页面如下:   selenium 最核心的技巧是WebElement的识别和定位 selenium总共有八种定位方法  By.id()  通过id定位 By.name()  通过name…
有时候我们在定位一个页面元素的时候发现一直定位不了,反复检查自己写的定位器没有任何问题,代 码也没有任何问题.这时你就要看一下这个页面元素是否在一个iframe中,这可能就是找不到的原因之一.如果你在一个default content中查找一个在iframe中的元素,那肯定是找不到的.反之你在一个iframe中查找另一个iframe元素或default content中的元素,那必然也定位不到. selenium webdriver中提供了进入一个iframe的方法: WebDriver org…
1.动态id定位不到元素for example:        //WebElement xiexin_element = driver.findElement(By.id("_mail_component_82_82"));        WebElement xiexin_element = driver.findElement(By.xpath("//span[contains(.,'写 信')]"));        xiexin_element.click…
1.动态id定位不到元素 for example:        //WebElement xiexin_element = driver.findElement(By.id("_mail_component_82_82"));        WebElement xiexin_element = driver.findElement(By.xpath("//span[contains(.,'写 信')]"));        xiexin_element.clic…
转载:http://www.51testing.com/html/87/300987-831171.html 1.动态id定位不到元素for example:        //WebElement xiexin_element = driver.findElement(By.id("_mail_component_82_82"));        WebElement xiexin_element = driver.findElement(By.xpath("//span[…