VineGlobal / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
1 stars 0 forks source link

how can i copy an image from selenium #75

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system : win 7
.Net Framework version : 4.0
Office Version : 2010
SeleniumWrapper version :

What is your issue ?

how can i copy an image from a webpage using selenium

I am trying to download here the google logo image 

Sub test()

Dim driver As New SeleniumWrapper.WebDriver

driver.Start "chrome"
driver.setImplicitWait 5000
driver.get ("http://www.google.com")
driver.findElementById("hplogo").getAttribute("src")

'i don't know how to save the image to a folder

end Sub

Original issue reported on code.google.com by alam...@gmail.com on 26 Jun 2014 at 2:03

GoogleCodeExporter commented 9 years ago
There is the getScreenshot method :
driver.findElementById("hplogo").getScreenshot().saveAs "image.png"

Or you can use the "src" attribute to get the link and then use it to download 
the image with some VB:
http://stackoverflow.com/questions/2973136/download-a-file-with-vbs

Original comment by florentbr on 26 Jun 2014 at 3:21

GoogleCodeExporter commented 9 years ago

Original comment by florentbr on 8 Sep 2014 at 5:40