无法单击图像链接并使用机械手类下载

时间:2018-10-05 10:51:07

标签: java selenium testng

我试图通过单击图像链接下载文件,但IEdriver陷入停顿。然后我尝试着重于元素并使用Robot类执行Keyboard Enter事件来执行下载,但未下载它是单击图像链接并刷新了表格。

 WebElement ele=driver.findElement(By.xpath("//img[@alt='145.36KB File Size']"));

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

    Robot robot = new Robot();
//get the focus on the element..don't use click since it stalls the driver          

 new Actions(driver).moveToElement(ele).perform();
//simulate pressing enter            
 robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

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

0 个答案:

没有答案