package tools;
/**
* @author Seven Qi
* @date 2012-8-31 下午5:51:51
* @version 1.0
*/
import org.openqa.selenium.WebDriver;
public class SwitchTo {
public static void SwitchToWindowByTitle(WebDriver driver, String title) {
for (String wd : driver.getWindowHandles()) {
driver.switchTo().window(wd);
if (driver.getTitle().equals(title))
break;
}
}
public static void SwitchToWindowByUrl(WebDriver driver, String url) {
for (String wd : driver.getWindowHandles()) {
driver.switchTo().window(wd);
if (driver.getCurrentUrl().equals(url))
break;
}
}
}
/**
* @author Seven Qi
* @date 2012-8-31 下午5:51:51
* @version 1.0
*/
import org.openqa.selenium.WebDriver;
public class SwitchTo {
public static void SwitchToWindowByTitle(WebDriver driver, String title) {
for (String wd : driver.getWindowHandles()) {
driver.switchTo().window(wd);
if (driver.getTitle().equals(title))
break;
}
}
public static void SwitchToWindowByUrl(WebDriver driver, String url) {
for (String wd : driver.getWindowHandles()) {
driver.switchTo().window(wd);
if (driver.getCurrentUrl().equals(url))
break;
}
}
}
====================================分割线================================
最新内容请见作者的GitHub页:http://qaseven.github.io/