google搜索 51Testing站内搜索                    软件测试门户 | 软件测试培 训 | 文章资料精选 | 软件测试论坛 | 软件测试博客 | 测试招聘求职 
打印

Html.HtmlBrowser属性的应用

本主题由 fishy 于 2007-11-22 10:03 提升

Html.HtmlBrowser属性的应用


刚开了个帖子,区分两个ie窗口的,有人说.windows窗口很土,但也不是一无是处。
.windows属性真的很土 ??
比如新开了两个空白的ie,所有的属性都是一样的。我们做测试的时候,通常是登录两个用户,一个用户提交,一个用户处理。
问题就在登录前,两个登录页面是相同的,如果采用一般的方法,务必会找到两个相同的对象,使测试无法继续。
工作中的一段代码:
try {
        Runtime.getRuntime().exec("tskill IEXPLORE");
        Runtime.getRuntime().exec("cmd.exe /c start IEXPLORE");
        Runtime.getRuntime().exec("cmd.exe /c start IEXPLORE");
} catch (IOException e) {
        e.printStackTrace();
}
sleep(8);
TestObject[] ieWin;
RootTestObject root = RootTestObject.getRootTestObject();
ieWin = root.find(atDescendant(".class", "Html.HtmlBrowser"));
System.out.println(ieWin.length);
if(ieWin.length<2){
        System.out.println("不能实现,没有找到2个ie窗口");
}else{
        BrowserTestObject BrowserWin_1=(BrowserTestObject)ieWin[0];
        BrowserTestObject BrowserWin_2=(BrowserTestObject)ieWin[1];
        BrowserWin_1.loadUrl("http://127.0.0.1:8080/demo");
        BrowserWin_2.loadUrl("http://127.0.0.1:8080/demo");
        GuiTestObject text_username1=(GuiTestObject)ieWin[0].find(atDescendant(".class","Html.INPUT.text",".name","userName"))[0];
        text_username1.setProperty(".value","username01");
        GuiTestObject text_username2=(GuiTestObject)ieWin[1].find(atDescendant(".class","Html.INPUT.text",".name","userName"))[0];
        text_username2.setProperty(".value","username02");
        GuiTestObject button1=(GuiTestObject)ieWin[0].find(atDescendant(".class","Html.INPUT.submit",".value","登录"))[0];
        button1.click();
        GuiTestObject button2=(GuiTestObject)ieWin[1].find(atDescendant(".class","Html.INPUT.submit",".value","登录"))[0];
        button2.click();
}

TOP

挺好挺好。呵呵。

[ 本帖最后由 lovetest6 于 2007-12-14 19:12 编辑 ]

Mercury Customer Support Portal为了RFT我卸载了QTP

TOP

 
当前时区 GMT+8, 现在时间是 2008-10-15 00:21Copyright(C)上海博为峰软件技术有限公司 2001-2007 电话:021-64471599-8017
当您在访问网站、论坛及博客过程中遇到问题时可发送email:webmaster@51testing.com或发送论坛短信至管理员风在吹