请在下面找到代码:
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);
请在打开弹出窗口时让我知道如何执行弹出处理代码,因为当我手动关闭弹出窗口时,只有弹出窗口处理代码不会在弹出窗口打开时执行。
如果问题没有提供令人满意的信息,请告诉我。
由于
答案 0 :(得分:0)
尝试使用Alert
类或PopupWindowFinder
链接中的代码基于c#,我希望您可以轻松将其转换为您想要的语言
popup's in selenium webdrivers