Selenium学习10--Frame操作
来源:互联网 发布:plc能用c语言编程吗 编辑:程序博客网 时间:2024/05/29 04:29
页面html代码如下:
<!doctype html><html lang="en"> <head> <title>frameset page title</title> </head><frameset cols = "25%,50%,25%"> <frame id="leftframe" src ="frame_left.html"/> <frame id="middleframe" src ="frame_middle.html"/> <frame id="rightframe" src ="frame_right.html"/></frameset> <body> </body></html><!doctype html><html lang="en"> <head> <title>left frame</title> </head> <body> <p>this is left frame text</p> </body></html><!doctype html><html lang="en"> <head> <title>middle frame title</title> </head> <body> <p> this is middle frame text</p> </body></html><!doctype html><html lang="en"> <head> <title>right frame title</title> </head> <body> <p> this is right frame text</p> </body></html>
页面效果如下
@Ignore public void testHandleFrame(){ driver.get("E:\\Java\\selenium_data\\html\\frameset_demo.html"); driver.switchTo().frame("leftframe"); WebElement leftFrameText = driver.findElement(By.xpath("//p")); Assert.assertEquals("this is left frame text", leftFrameText.getText()); //如果不调用defaultContent()方法,frame无法切换到其他frame中 driver.switchTo().defaultContent(); //frame(int index)方法调用切换frame driver.switchTo().frame(1); System.out.println(driver.findElement(By.xpath("//p")).getText()); }
@Test public void testHandleFrameByPageSource(){ driver.get("E:\\Java\\selenium_data\\html\\frameset_demo.html"); List<WebElement> frames = driver.findElements(By.tagName("frame")); for(WebElement frame:frames){ driver.switchTo().frame(frame); if(driver.getPageSource().contains("middle frame")){ Assert.assertEquals("this is middle frame text", driver.findElement(By.xpath("//p"))); }else{ driver.switchTo().defaultContent(); } } driver.switchTo().defaultContent(); }
0 0
- Selenium学习10--Frame操作
- Selenium + Webdriver 学习(五) frame下元素定位
- Selenium + Webdriver 学习(五) frame下元素定位
- Selenium学习笔记之008:多层frame或者windows定位
- selenium 学习5 -- 基本操作
- selenium技术学习-浏览器操作
- selenium switch_to.frame
- 【Selenium】13Frame
- frame操作
- 14、Selenium + Python 实现 UI 自动化测试-操作Frame(iFrame)
- python+selenium 如何跳出frame
- selenium 学习札记5-基本操作
- 【selenium学习笔记】webdriver操作浏览器
- 【Selenium学习笔记】webdriver操作下拉框
- Selenium学习笔记之011:操作对象
- 【Python】学习selenium自动化测试:操作浏览器
- Selenium学习笔记3--元素操作
- R学习03(data.frame详细操作)
- linux并发同步
- 0001-每日一记(2016-09-15)
- JavaScript-前端加密(广义),防止js篡改
- 第三周项目3-求集合并集
- Qt学习之十六:Qt绘制系统简介
- Selenium学习10--Frame操作
- DB2 del文件导出指定分隔符问题
- 逆天,自我意识
- eclipse中建立servlet时会提示没有导入javax.servlet包解决办法
- Ubuntu下boot分区剩余空间不足解决
- 既爱又恨的inline-block
- LeetCode34. Search for a Range
- 线性插值
- NOIP 提高组【JZOJ 4777】灌水