DEV Community

Discussion on: Automate Taking Website Screenshots With Selenium in Python

Collapse
 
smirza profile image
Suhail

Thanks a lot, Bilal for sharing this. Curious to know if this solution is OS dependent.

Collapse
 
bk profile image
BK ☕

Suhail, I have updated my post if you're interested in Headless Chrome.

Collapse
 
smirza profile image
Suhail

Thanks a ton Bilal :)

Collapse
 
bk profile image
BK ☕ • Edited

Hello Suhail, you're very welcome.
I am on my Mac right now, so I had the chance to do a quick test.
All I had to do is download Chrome Webdriver for MacOS from the link provided in the post, installed selenium with pip. Of course I had the change the path to the webdriver, I ran the python script and it worked with no additional tweaking.

Another tip, if you'd like to run the job with Chrome headless:

# imports here
# links = [array of links]

options = webdriver.ChromeOptions()
options.add_argument('headless')

with webdriver.Chrome('/Users/userName/chromedriver', chrome_options=options) as driver:
    # code here

I tested the headless on MacOS, I am trying to test this on Ubuntu on a remote server. I'll update the post if I succeed.

Collapse
 
smirza profile image
Suhail

Nice work Bilal, Thanks a lot for the effort.