How to download Image using Webdriver??????

170 views
Skip to first unread message

sridhar ..

unread,
Nov 26, 2012, 1:51:53 AM11/26/12
to webd...@googlegroups.com
Hi ALL,

Could any one help me regarding how to download Image using selenium webdriver.

I tried like below but not working

WebElement copyimage=driver.findElement(By.id("welcome-home-container"));
System.out.println(copyimage.isDisplayed());
copyimage.sendKeys("C:\\Documents and Settings\\irbmfq\\Desktop\\Nexialogo1.png");


Advance Thanks...
My.

Abhi

unread,
Nov 26, 2012, 2:05:06 AM11/26/12
to webd...@googlegroups.com
Hi sridhar,

first create a browser profile by bellow code and than in @test click on download img link, it will save yr img file to mansion path in profile .......

try this .... might be will help u....

DesiredCapabilities browserCapabillities = DesiredCapabilities.firefox(); 
            browserCapabillities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
            FirefoxProfile firefoxprofile = new FirefoxProfile();
            firefoxprofile.setEnableNativeEvents(true);
            firefoxprofile.setAssumeUntrustedCertificateIssuer(true);
            // set the Profile to download file without asking save or to store location.
            firefoxprofile.setPreference("browser.download.folderList", 2);             //   (browser.download.folderList are internal methods of the FF profile and 2 is the corresponding value of the location.)
            firefoxprofile.setPreference("browser.download.dir", "C:\\Users\\abhishek.singh\\Downloads\\Selenium");             //  path where I have to store the file.
            firefoxprofile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword,application/csv,text/csv,application/pdf"); //Add the MIME code of your file here.
            //firefoxprofile.setPreference("browser.download.manager.showWhenStarting", "false");
            firefoxprofile.setPreference("browser.download.useDownloadDir", "false");
            webDriver = new FirefoxDriver(firefoxprofile);

Abhishek

Manoj

unread,
Nov 28, 2012, 6:56:11 AM11/28/12
to webd...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages