我正在努力处理单击 img 图标时显示的弹出(查找)窗口
代码:
String parentHandle = LoginPage2.driver.getWindowHandle();
LoginPage2.driver.findElement(By.id("opp4_lkwgt")).click();
//after you have pop ups
Set s = LoginPage2.driver.getWindowHandles();
Iterator ite=s.iterator();
while(ite.hasNext())
{
String popupHandle=ite.next().toString();
if(!popupHandle.contains(parentHandle))
{
LoginPage2.driver.switchTo().window(popupHandle);
//here you can perform operation in pop-up window**
TimeUnit.SECONDS.sleep(8);
LoginPage2.driver.findElement(By.id("lksrch")).sendKeys("sss");
//After finished your operation in pop-up just select the main window again
LoginPage2.driver.switchTo().window(parentHandle);
LoginPage2.driver.close();
}
}
我的代码没有集中到查找弹出窗口,我无法sss
在搜索字段中输入。
查找窗口的 HTML:
<div class="pBody">
<div class="message infoM4" id="msgBox">
<table class="messageTable" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td>
<img src="/s.gif" alt="Information" class="msgIcon" title="Information">
</td>
<td class="messageCell"><div class="messageText">Opportunities cannot go against a Global Parent. Please select an Organisation that is lower in the hierarchy than a Global Parent.</div></td></tr>
</tbody></table></div><*script type="text/javascript">if (window.sfdcPage) sfdcPage.registerMessage('msgBox');</script>
<label for="lksrch">Search</label>
<input id="lksrch" maxlength="80" name="lksrch" size="20" type="text" value="">
<input value=" Go! " class="btn" name="go" title="Go!" type="submit">
<input value=" New " class="btn" name="new" onclick="javascript:top.resultsFrame.location='LookupResultsFrame?lktp=001&lkfm=editPage&lknm=opp4&lksrch=&lknew=1&lkent=006&lkfield=Account&igdp=0'" title="New" type="button">
<div class="bDescription"></div></div>