【发布时间】:2016-08-17 21:24:09
【问题描述】:
请在下面找到代码:
d.findElement(By.id("txtUserName")).clear();
d.findElement(By.id("txtUserName")).sendKeys("polarissupport@polaristest.net");
Thread.sleep(2000);
d.findElement(By.name("txtTempBox")).clear();
Thread.sleep(2000);
d.findElement(By.id("txtPassword")).sendKeys("password");
d.findElement(By.id("btnsubmit")).click();
Thread.sleep(2000);
d.findElement(By.id("ctl00_ContentPlaceHolder1_rdoAdmin")).click();
Thread.sleep(2000);
d.findElement(By.id("ctl00_ContentPlaceHolder1_lnkContinue")).click();
Thread.sleep(5000);
//GC Inbox
String s1 = "CHR-665";//d.findElement(By.id("ctl00_ContentPlaceHolder1_lblrequestidtext")).getText(); //For taking Request Id
String tem[] = s1.split("-");
d.findElement(By.id("ctl00_ContentPlaceHolder1_ctlCommonInbox_txtGrantID")).sendKeys(tem[1]);
d.findElement(By.id("ctl00_ContentPlaceHolder1_ctlCommonInbox_lnkSearch")).click();
Thread.sleep(5000);
d.findElement(By.id("ctl00_ContentPlaceHolder1_ctlCommonInbox_grdAdminGrantCHR_ctl00_ctl04_btnAction")).click();
Thread.sleep(8000);
d.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_lnkReleasePayment']")).click();
在打开弹出窗口的最后一行之后,无法执行代码来处理这个打开的弹出窗口。 请在下面找到我处理弹出窗口的代码:
String MainWindow=d.getWindowHandle();
Set<String> set=d.getWindowHandles();
Iterator<String> it=set.iterator();
while(it.hasNext())
{
System.out.println("Inside While");
String ChildWindow=it.next();
if(!MainWindow.equalsIgnoreCase(ChildWindow))
{
d.switchTo().window(ChildWindow);
d.close();
}
}
System.out.println("Outside While");
d.switchTo().window(MainWindow);
请告诉我如何在弹出窗口打开时执行弹出窗口处理代码,因为当我手动关闭弹出窗口时,只有这个弹出窗口处理代码在弹出窗口打开时不执行。
如果问题没有提供令人满意的信息,请告诉我。
谢谢
【问题讨论】:
-
你能张贴弹出图像吗?你确定弹出窗口不是基于窗口的吗?
-
@ChanChow:是的,我确定它不是基于 Windows 的,因为弹出窗口中有 URL。顺便说一下,我无法在此处发布图片,所以请告诉我如何发布如果您想查看弹出图像,请点击此处。谢谢。