Skip to content

Commit

Permalink
testing actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubdotpy3d committed Jan 11, 2025
1 parent 9795277 commit 6c35330
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 7 deletions.
26 changes: 25 additions & 1 deletion .github/scripts/take_screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,28 @@

print(f'cookie: {cookie:10}')

print('taking screenshot')
from io import BytesIO

from PIL import Image
from selenium import webdriver

fox = webdriver.Firefox()
fox.get('http://stackoverflow.com/')

# now that we have the preliminary stuff out of the way time to get that image :D
element = fox.find_element_by_id('hlogo') # find part of the page you want image of
location = element.location
size = element.size
png = fox.get_screenshot_as_png() # saves screenshot of entire page
fox.quit()

im = Image.open(BytesIO(png)) # uses PIL library to open image in memory

left = location['x']
top = location['y']
right = location['x'] + size['width']
bottom = location['y'] + size['height']


im = im.crop((left, top, right, bottom)) # defines crop points
im.save('screenshot.png') # saves new cropped image
12 changes: 6 additions & 6 deletions .github/workflows/update_readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Install Python and Playwright
run: |
pip install uv
uvx playwright install
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install the project
run: uv sync --all-extras --dev

- name: Take Screenshot
env:
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ dev = [
"pre-commit>=4.0.1",
"ruff>=0.8.1",
]
actions = [
"pillow>=11.0.0",
"selenium>=4.27.1",
]

# --- tools configuration ---

Expand Down
187 changes: 187 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c35330

Please sign in to comment.