Saturday 3 May 2014

Browser pop-ups or file uploads can be handled using Java API Robot class

Selenium is not a tool for saving attachments etc. But  you can  solve your problem. Simple example:

    @Test
    public void downloadFromIbmlalala() throws AWTException {   
        driver = new FirefoxDriver();
        driver.get(baseUrl);
        try {
        WebElement buttonFromPage = driver.findElement(By.name("verify"));
        buttonFromPage.click();
        (new Robot()).keyPress(java.awt.event.KeyEvent.VK_ENTER);
    } catch (AWTException e) {
        e.printStackTrace();
    }
    }

and attachment is saved in default location. If it’s a good idea to save attachments in automations testing? Don’t think so… But it can be done

No comments:

Post a Comment