代码是没有得到执行硒
问题描述:
打开弹出后,请找到下面的代码:代码是没有得到执行硒
d.findElement(By.id("txtUserName")).clear();
d.findElement(By.id("txtUserName")).sendKeys("[email protected]");
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);
请让我知道如何在弹出窗口被打开,因为当我关闭弹出式手动然后执行弹出处理代码只有此Pop-up处理代码不在Pop-up打开时执行。
如果问题没有提供令人满意的信息,请让我知道。
感谢
答
尝试使用Alert
类或链接PopupWindowFinder
代码是基于C#,我希望你可以将其转换为所需的语言轻松 popup's in selenium webdrivers
+0
感谢您的答复。我在下面的代码中找到了解决方案.click():((JavascriptExecutor)driver).executeScript(“window.showModalDialog = window.open;”);这将调用window.open而不是window.showModalDialog。 –
您可以张贴在弹出的形象呢?你确定弹出窗口不是基于Windows的吗? – ChanChow
@ChanChow:是的,我确定它不是基于Windows的,因为URL存在于Popup中。通过我无法在此处发布图片的方式,请让我知道如何在此处发布,如果您想查看弹出图像。谢谢。 –