sarmisen / selenium-vba

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

Capturing Screenshots to JPEG file #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system : Win7
.Net Framework version : 2.0.7045
Office Version : 2003
SeleniumWrapper version : 1.0.11.0

Could you please provide example of VBA Code to capture Screenshot and save it 
as JPEG file.

Below is a code example from your homepage saving Screenshots as PDF files. 
This is exactly what I would possibly need, except for saving as JPEG file. 
Also one screenshot per file is absolutely fine.

Set selenium = CreateObject("SeleniumWrapper.WebDriver")
Set pdf = CreateObject("SeleniumWrapper.PdfFile")
selenium.start "firefox", "http://www.google.com"
selenium.open "search?q=eiffel+tower"
pdf.addImage selenium.getScreenshot(), "Google search - Eiffel tower"
selenium.open "http://maps.google.com/maps?q=eiffel+tower"
pdf.addImage selenium.getScreenshot(), "Google map - Eiffel tower"
pdf.saveAs "c:\selenium-capture.pdf"
selenium.stop

Many thanks in advance

Original issue reported on code.google.com by steepd...@gmail.com on 14 Apr 2013 at 12:38

GoogleCodeExporter commented 9 years ago
Try this :

Dim selenium As New SeleniumWrapper.WebDriver
selenium.start "firefox", "http://www.google.com"
selenium.open "search?q=eiffel+tower"
selenium.getScreenshot().SaveAs "c:\image1.png"
selenium.Open "maps?q=eiffel+tower"
selenium.getScreenshot().SaveAs "c:\image2.png"
selenium.stop

Original comment by florentbr on 15 Apr 2013 at 11:59