forked from florentbr/SeleniumBasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaptureToPdf(Firefox).vbs
More file actions
51 lines (40 loc) · 3.67 KB
/
CaptureToPdf(Firefox).vbs
File metadata and controls
51 lines (40 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
' ---------------------------------------------------------------------------------------
' Search for "Eiffel tower", create a Pdf and insert a screen capture of the page result.
' ---------------------------------------------------------------------------------------
Class Script
Dim driver
Sub Class_Initialize
Set driver = CreateObject("Selenium.FirefoxDriver")
Set pdf = CreateObject("Selenium.PdfFile")
'Define the PDF page size and margins
pdf.SetPageSize 210, 297, "mm"
pdf.SetMargins 5, 5, 5, 15, "mm"
'Add a title and some text to the PDF
pdf.AddTextCenter "Search for Eiffel tower", 14, true
pdf.AddSpace 10
pdf.AddText "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " & _
"Etiam sit amet libero arcu, et molestie purus. Ut in sem lacus, " & _
"sit amet rhoncus erat. In aliquet arcu at nunc porta sollicitudin. " & _
"Cras ante nisl, hendrerit quis bibendum quis, egestas vitae mi."
'Open the search page and maximize the window
driver.Get "https://www.google.co.uk"
driver.Window.Maximize
'Add a title, the URL and a screenshot to the PDF
pdf.AddTitle "Search page"
pdf.AddLink driver.Url
pdf.AddImage driver.TakeScreenshot()
'Search for Eiffel tower
driver.Get "/search?q=Eiffel+tower"
'Add a title, the URL and a screenshot to the PDF
pdf.AddTitle "Results page"
pdf.AddLink driver.Url
pdf.AddImage driver.TakeScreenshot()
'Save the PDF to a file
pdf.SaveAs "my-capture-ff.pdf"
End Sub
Sub Class_Terminate
driver.Quit 'Stops the browser
End Sub
End Class
Set s = New Script