|
方法1.取 href ,再用open(当时是为了走通流程)
方法2.修改被测页面的<a> 元素打开页面的方式-
- //模拟打开子窗口
- //用窗口打开
- selenium.getEval("this.page().findElement(\""+picXpath+"\").removeAttribute('target')");
- selenium.getEval("this.page().findElement(\""+picXpath+"\").href=\"javascript:window.open('"+picUrl+"','p4pwindow','scrollbars=yes')\"");
- selenium.click(picXpath);
- Thread.sleep(100);
- selenium.selectWindow("name=p4pwindow");
- String bigPic=selenium.getAttribute("//img[@id='J_ImgBooth']@src");
-
- //add code
- selenium.getEval("javascript:window.close();");
- selenium.selectWindow("name=mywindow");
复制代码
方法3:在单击弹出后,用selenium.getAllWindowTitles(),取最后一个title(这个我暂时没有用到,因title都一样)selenium.click(picXpath);
String[] titles=selenium.getAllWindowTitles();
selenium.selectWindow("title="+titles[titles.length-1]+"");
//add code
selenium.close();
方法4:autoit, 一点点来模拟.(vbs,代码片)Set objArgs = WScript.Arguments
Set oAutoIt = CreateObject("AutoItX3.Control")
oAutoIt.WinActivate "untitled", ""
oAutoIt.WinWaitActive "untitled","",5
oAutoIt.MouseClick "left", objArgs(0), objArgs(1), 1
rem
oAutoIt.AutoItSetOption "WinTitleMatchMode", 2
'set title = oAutoIt.WinGetTitle("_更多", "")
oAutoIt.WinActivate "_更多", ""
oAutoIt.WinWaitActive "_更多", "",5
希望高人能提供更好的方法共享。
[ 本帖最后由 小米啊 于 2010-5-15 09:48 编辑 ] |
|