vendredi 5 octobre 2018

stalls IEdriver when download link is clicked

I am automating download testing on IE using robot class but when download link is clicked driver stalled and don't respond further and can't control save and open dialogue that pop up in IE. enter image description here

// driver stalled while clicking this
   driver.findElement(By.xpath("//img[@alt='145.36KB File Size']")).click();

    Thread.sleep(5000);
    System.out.println("Robot class");

           try {
       Robot robot = new Robot();


     //simulate pressing enter            
    robot.keyPress(KeyEvent.VK_ENTER);
   robot.keyRelease(KeyEvent.VK_ENTER);
   //wait for the modal dialog to open            
   Thread.sleep(2000);
  //press s key to save            
  robot.keyPress(KeyEvent.VK_S);
  robot.keyRelease(KeyEvent.VK_S);
 Thread.sleep(2000);
 //press enter to save the file with default name and in default location
  robot.keyPress(KeyEvent.VK_ENTER);
 robot.keyRelease(KeyEvent.VK_ENTER);
  } catch (AWTException e) {

    e.printStackTrace();
    }
            Thread.sleep(4000);
            driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

Aucun commentaire:

Enregistrer un commentaire