Take a Screenshot of a web page and “Click” buttons in a web page

Here we will take a screen shot of the Ocean Viewer page. Since it has a welcome alert that we do not want included in the screenshot we closed the welcome alert before taking the screen shot.

Ocean Viewer Screen Shot

 

#Import Selenium Webdriver
from selenium import webdriver

#open Fire fox
driver = webdriver.Firefox()

# Resize the window to the desired screen width/height
driver.set_window_size(1300, 800)

#Open URL
driver.get('http://oceanviewer.org/atlantic-canada/temperature/')

# Close welcome screen
#To find element id right click on button and hit select inspect element 
#The name will be in a bubble above the text. 
#In our case the element id is close welcome screen 
driver.find_element_by_id("close_welcome").click()

#save screenshot
driver.save_screenshot('screenshot1.png')

#close window
driver.quit()

Advertisements

4 thoughts on “Take a Screenshot of a web page and “Click” buttons in a web page

  1. I drop a leave a response when I appreciate a post on a website or I have something to add to the conversation.
    It’s a result of the fire displayed in the post I read.
    And on this post Take a Screenshot of a web page and Click buttons in a web page | Ocean Python.
    I was actually moved enough to write a comment 😛 I
    do have a couple of questions for you if you do not mind.
    Is it simply me or does it look like like a few of the remarks come across like they are left by brain
    dead visitors? 😛 And, if you are writing at additional online social sites, I would like to keep up
    with anything fresh you have to post. Could you list
    every one of all your community sites like your linkedin profile, Facebook page or
    twitter feed?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s