码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-09-23 19:41:15      阅读:165      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!