I am trying to save an image by using save as option inside a specific folder. I found a way by which I am able to right click on the image which I want to save using save as option. But the problem where I am stuck is after getting the os window which asks where to save the file I am not able to send the desired location because I don't know how to do it. I went through the similar questions asked on this forum but non of them helped so far.
Code is-
For Firefox-
public class practice {
public void pic() throws AWTException{
WebDriver driver;
//Proxy Setting
FirefoxProfile profile = new FirefoxProfile();
profile.setAssumeUntrustedCertificateIssuer(false);
profile.setEnableNativeEvents(false);
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "localHost");
profile.setPreference("newtwork.proxy.http_port",3128);
//Download setting
profile.setPreference("browser.download.folderlist", 2);
profile.setPreference("browser.helperapps.neverAsk.saveToDisk","jpeg");
profile.setPreference("browser.download.dir", "C:\\Users\\Admin\\Desktop\\ScreenShot\\pic.jpeg");
driver = new FirefoxDriver(profile);
driver.navigate().to("http://stackoverflow.com/users/2675355/shantanu");
driver.findElement(By.xpath("//*[@id='large-user-info']/div[1]/div[1]/a/div/img"));
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.xpath("//*[@id='large-user-info']/div[1]/div[1]/a/div/img"))).perform();
action.contextClick().perform();
Robot robo = new Robot();
robo.keyPress(KeyEvent.VK_V);
robo.keyRelease(KeyEvent.VK_V);
// Here I am getting the os window but don't know how to send the desired location
}//method
}//class
For chrome-
public class practice {
public void s() throws AWTException{
WebDriver driver;
System.setProperty("webdriver.chrome.driver","C:\\Users\\Admin\\Desktop\\chromedriver.exe");
driver = new ChromeDriver();
driver.navigate().to("http://stackoverflow.com/users/2675355/shantanu");
driver.findElement(By.xpath("//*[@id='large-user-info']/div[1]/div[1]/a/div/img"));
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.xpath("//*[@id='large-user-info']/div[1]/div[1]/a/div/img"))).perform();
action.contextClick().perform();
Robot robo = new Robot();
robo.keyPress(KeyEvent.VK_V);
robo.keyRelease(KeyEvent.VK_V);
// Here I am getting the os window but don't know how to send the desired location
}
}