–
Question/Requirement:
1. I just navigated to the webpage “http://humblelittlerubybook.com/book/hlrb.pdf”
2. I want to Save the web page as a PDF File.
Solution:
1. Install Ruby
2. Install Watir-webdriver (CMD>gem install watir-webdriver)
3. Register Autoitx3.dll (https://raveendran.wordpress.com/2012/06/15/how-to-installregister-autoitx3-dll/)
4. Run the Below Script
Code:
require 'rubygems'
require 'watir-webdriver'
require 'win32ole'
ie=Watir::Browser.new :ie
ie.goto(“http://humblelittlerubybook.com/book/hlrb.pdf”)
sleep 15
$autoit = WIN32OLE.new(“AutoItX3.Control”)
$autoit.Send(“{ALTDOWN}”)
sleep 3
$autoit.Send(“f”)
sleep 3
$autoit.Send(“{ALTUP}”)
sleep 3
$autoit.Send(“{DOWN}”)
sleep 3
$autoit.Send(“{DOWN}”)
sleep 1
$autoit.Send(“{DOWN}”)
sleep 1
$autoit.Send(“{DOWN}”)
sleep 1
$autoit.Send(“{DOWN}”)
sleep 1
$autoit.Send(“{DOWN}”)
sleep 1
$autoit.Send(“{ENTER}”)
sleep 10
$autoit.Send(“D:\\test1.pdf”)
sleep 3
$autoit.Send(“{TAB}”)
sleep 1
$autoit.Send(“{TAB}”)
sleep 1
$autoit.Send(“{ENTER}”)
sleep 1
Note:
1. Depends upon your browser you may need to add/remove the {TAB} and {DOWN} lines
2. Change the destination folder.
Output:
PDF file saved in the mentioned location D:\\test1.pdf