2

I am new to Python and currently I am working on a program to capture full page screen and email it to specific persons. I have done the email part well. But I am finding difficulty to find a python script that clicks on "Full Page Screen Capture" button in Google Chrome using Python Script. May I know is there a way for that? I have to take the screenshot by clicking "Full Page Screen Capture" button only. It will be a great help if someone could help me. Thanks in advance!

NOTE: Requesting to kindly note that, I DON'T WANT TO TAKE SCREENSHOT! Screenshot only takes the contents available on that particular screen. "Full Page screen Capture" button helps to capture the entire web page even if it is not visible in screen. MAY I HAVE A SCRIPT WHICH HELPS ME TO CLICK ON THAT BUTTON IN CHROME?

I have searched for script that clicks a web browser button. Unfortunately, I could only find scripts that helps to click web page button.

anaghapramesh
  • 77
  • 1
  • 2
  • 11

2 Answers2

7

There is a python library/module called selenium that allows you to automate your browser and supports multiple web browsers such as Chrome, Firefox and more.

You can get started by installing selenium using pip install selenium and then following the instructions included above to get drivers.

Here is a quick starting script for taking a screenshot (in this example i will be using Chrome)

from selenium import webdriver

browser = webdriver.Chrome()

browser.get('https://python.org')
browser.save_screenshot("screenshot.png")

browser.close()
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
MrKioZ
  • 515
  • 4
  • 14
2

You could look into PyAutoGUI. You can automate hotkeys, clicks, etc.

pyautogui.click(x=moveToX, y=moveToY, clicks=num_of_clicks, interval=secs_between_clicks, button='left') 

It does have a screenshot function, though I'm not sure if it is what you are looking for since you wanted to use Chrome's built-in function

pyautogui.screenshot('foo.png')

or if you only wanted a certain part of the screen/webpage

pyautogui.screenshot(region=(0,0, 300, 400))
Matt M
  • 691
  • 2
  • 6
  • 17
  • 1
    I believe PyAutoGUI has a screenshot function too that should probably be included in your post! – Reedinationer May 15 '19 at 18:00
  • I didn't include it originally since it really isn't Chrome's screenshot function. But I added it in – Matt M May 15 '19 at 18:04
  • 1
    Yeah, true. OP could potentially have it in full screen mode (with `F11`) in which case it would be the same though. Good call to include the optional `region` argument though. I think between the two answers the problem should be easily solvable! – Reedinationer May 15 '19 at 18:06