1

我正在努力处理单击 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&amp;lkfm=editPage&amp;lknm=opp4&amp;lksrch=&amp;lknew=1&amp;lkent=006&amp;lkfield=Account&amp;igdp=0'" title="New" type="button">

<div class="bDescription"></div></div>
4

1 回答 1

0

尝试先发送一个空白键,以便元素获得焦点,然后发送“sss”

element = LoginPage2.driver.findElement(By.id("lksrch"));
element.sendKeys(" ");
element.sendKeys("sss");
于 2013-01-03T22:17:24.333 回答