首页 > 其他 > 详细

来回切换页面并关闭其他tab

时间:2016-09-23 19:41:11      阅读:182      评论:0      收藏:0      [点我收藏+]

要下班了,就先把这个方法copy上来。反正自己能看懂。

public void checkSchemaDetail(String logext, String expectRes){
String currentWindow = driver.getWindowHandle();
schemaDetail.click();
Set<String> windowSet = driver.getWindowHandles();
for(String window : windowSet){
if(!window.equals(currentWindow)){
driver.switchTo().window(window);
logger.warn(logext+" the attached url of schemaDetail is "+driver.getCurrentUrl());
if(expectRes != null && !expectRes.equals("")){
WebElement schemeId = driver.findElement(By.name("id"));
WebElement schemeName = driver.findElement(By.name("name"));
String actualRes = schemeId.getAttribute("value")+" : "+schemeId.getAttribute("value");
if(expectRes.equals(actualRes))
logger.info("the schemeId and schemeName of jumped page is all right");
else
logger.warn("the schemeId and schemeName of jumped page expect: "+expectRes+", actual: "+actualRes);
}
driver.close(); //只会关掉当前tab,用qiut会关掉整个浏览器
}
}
driver.switchTo().window(currentWindow);
}

来回切换页面并关闭其他tab

原文:http://www.cnblogs.com/jefzha/p/5901081.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!