compare: pass url as command argument
This commit is contained in:
parent
9a37473f93
commit
566b9ae239
4
TODO
4
TODO
|
@ -1,6 +1,6 @@
|
|||
* Make a compare subcommand
|
||||
* Pass url to compare as command argument
|
||||
* Pass screenshots directory as command arguments
|
||||
* See how to pass css overwrite options efficiently to command line
|
||||
* Take screenshot of page with and without overwritten CSS
|
||||
* Compare CSS for differences
|
||||
* Compare output image for differences
|
||||
* Pass resolution as command argument
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from asyncio import run
|
||||
from click import group
|
||||
from click import argument
|
||||
from click import pass_context
|
||||
from functools import update_wrapper
|
||||
from playwright.async_api import Route
|
||||
|
@ -32,15 +33,16 @@ async def get_css(route: Route) -> None:
|
|||
|
||||
|
||||
@cli.command()
|
||||
@argument('url', type=str)
|
||||
@pass_context
|
||||
@async_command
|
||||
async def compare(ctx):
|
||||
async def compare(ctx, url):
|
||||
async with async_playwright() as p:
|
||||
browser = await p.firefox.launch()
|
||||
context = await browser.new_context()
|
||||
await context.route(re_compile(r'.*\.css(.map)?.*'), get_css)
|
||||
page = await context.new_page()
|
||||
await page.goto("https://demarches.auch.fr/")
|
||||
await page.goto(url)
|
||||
screenshot_bytes = await page.screenshot()
|
||||
with open('/home/csechet/screenshot.png', 'wb') as screenshot_file:
|
||||
screenshot_file.write(screenshot_bytes)
|
||||
|
|
Loading…
Reference in New Issue