0

I am unable to switch between windows. Cursor got struck on opening the popup. Unable to move any further. Test case: Open the URL: http://voltaerp.cloudapp.net/VomsDemoV2/ Click on Enquiries tab and then click on sub menu item “Foreign enquiry”. This will redirect the user to foreign enquiry page. Now click on the green plus symbol + to select an item from the POP-UP. I am good till now. Once the window opens the code gets stuck. Unable to read the ID of the Pop-up or switch the driver to pop-up so that I can select any item. Please help

This the code I used

    Public void main (string[]args)

    {             
         WebDriver driver=new FirefoxDriver();

         driver.get(“voltaerp.cloudapp.net/VomsDemoV2/");

         driver.findElement(By.id("txtUser")).clear();

         driver.findElement(By.id("txtUser")).sendKeys("testmail_b@yahoo.com");

         Thread.sleep(500);

         driver.findElement(By.id("txtPass")).clear();

         driver.findElement(By.id("txtPass")).sendKeys("123456");

         driver.findElement(By.id("btnLogin")).click();

         driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);

         WebElement parentlink= driver.findElement(By.id("ctl00_NavigationMenun3"));
         Actions hover= new Actions(driver);
         hover.moveToElement(parentlink).build().perform();


         WebElement sublink= driver.findElement(By.linkText("FOREIGN ENQUIRY"));
         Actions Fe= new Actions(driver);
         Fe.moveToElement(sublink).click().build().perform();

         driver.findElement(By.id("ctl00_ContentPlaceHolder1_gv_itms_ctl03_imgbtnAddItem")).click(); 

//Unable to move further. cursur is not going to next statement when I am debugging the code.

         Set<String> WindowIds = driver.getWindowHandles();
         Iterator<String> itr = WindowIds.iterator();
         String mainwindow = itr.next();
         String Popup = itr.next();

         driver.switchTo().window(Popup);

         driver.findElement(By.xpath(".//*[@id='txtItmDscrip']")).sendKeys("TESTITEM");

    }
4

1 回答 1

0

由于应用程序需要身份验证,因此无法检查您的方案。但通常弹出不是一个窗口,而只是一个警报。尝试使用 Alert 类来处理它。

Alert alert = driver.switchTo().alert();

有关更多详细信息,请参见此处。在 Java 文档页面上,单击 LHS 框架上的警报链接。

于 2013-10-24T06:06:18.950 回答