webspec 在新窗口打开链接

来源:互联网 发布:旅游数据统计 编辑:程序博客网 时间:2024/04/27 14:00

package com.guet.wpest;


import org.watij.webspec.dsl.WebSpec;


/**
 * @author 
 * @version 创建时间:2012-8-16 下午5:27:24
 * 
 */
public class TestNewWindow
{


/**
* @param args
* @throws Exception 
*/
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception
{
WebSpec spec = new WebSpec().ie();
spec.open(“www.baidu.com");
while (true)
{
Thread.sleep(1000);
for (int i = 0; i < spec.browserCount(); i++)
{
spec.browser(i).execute("var aObject = document.getElementsByTagName(\"a\");"
+ "for(var i =0;i<aObject.length;i++){"
+ "aObject"+ "[i]" + ".target" + "=\"_block\";" +" }");
System.out.println(spec.browserCount());
}


}
}


}