mirror of
https://github.com/nextcloud/docker.git
synced 2025-03-14 18:35:08 +01:00
Headless new mode introduced for chrome
This commit is contained in:
parent
e77d27ed5b
commit
6e3ddc458a
6 changed files with 45 additions and 36 deletions
|
@ -11,10 +11,11 @@ def log_note(message: str) -> None:
|
|||
def run(playwright: Playwright, browser_name: str) -> None:
|
||||
log_note(f"Launch browser {browser_name}")
|
||||
if browser_name == "firefox":
|
||||
browser_type = playwright.firefox
|
||||
browser = playwright.firefox.launch(headless=True)
|
||||
else:
|
||||
browser_type = playwright.chromium
|
||||
browser = browser_type.launch(headless=True)
|
||||
# this leverages new headless mode by Chromium: https://developer.chrome.com/articles/new-headless/
|
||||
# The mode is however ~40% slower: https://github.com/microsoft/playwright/issues/21216
|
||||
browser = playwright.chromium.launch(headless=False,args=["--headless=new"])
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
try:
|
||||
|
|
|
@ -10,12 +10,12 @@ def log_note(message: str) -> None:
|
|||
|
||||
def run(playwright: Playwright, browser_name: str) -> None:
|
||||
log_note(f"Launch browser {browser_name}")
|
||||
headless = True
|
||||
if browser_name == "firefox":
|
||||
browser = playwright.firefox.launch(headless=headless)
|
||||
browser = playwright.firefox.launch(headless=True)
|
||||
else:
|
||||
browser = playwright.chromium.launch(headless=headless)
|
||||
|
||||
# this leverages new headless mode by Chromium: https://developer.chrome.com/articles/new-headless/
|
||||
# The mode is however ~40% slower: https://github.com/microsoft/playwright/issues/21216
|
||||
browser = playwright.chromium.launch(headless=False,args=["--headless=new"])
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
|
||||
|
|
|
@ -11,10 +11,11 @@ def log_note(message: str) -> None:
|
|||
def create_user(playwright: Playwright, browser_name: str, username: str, password: str) -> None:
|
||||
log_note(f"Launch browser {browser_name}")
|
||||
if browser_name == "firefox":
|
||||
browser_type = playwright.firefox
|
||||
browser = playwright.firefox.launch(headless=True)
|
||||
else:
|
||||
browser_type = playwright.chromium
|
||||
browser = browser_type.launch(headless=True)
|
||||
# this leverages new headless mode by Chromium: https://developer.chrome.com/articles/new-headless/
|
||||
# The mode is however ~40% slower: https://github.com/microsoft/playwright/issues/21216
|
||||
browser = playwright.chromium.launch(headless=False,args=["--headless=new"])
|
||||
context = browser.new_context()
|
||||
try:
|
||||
page = context.new_page()
|
||||
|
|
|
@ -19,15 +19,21 @@ def log_note(message: str) -> None:
|
|||
def collaborate(playwright: Playwright, browser_name: str) -> None:
|
||||
log_note(f"Launch two {browser_name} browsers")
|
||||
if browser_name == "firefox":
|
||||
browser_type = playwright.firefox
|
||||
browser = playwright.firefox.launch(headless=True)
|
||||
else:
|
||||
browser_type = playwright.chromium
|
||||
|
||||
browser = browser_type.launch(headless=True)
|
||||
# this leverages new headless mode by Chromium: https://developer.chrome.com/articles/new-headless/
|
||||
# The mode is however ~40% slower: https://github.com/microsoft/playwright/issues/21216
|
||||
browser = playwright.chromium.launch(headless=False,args=["--headless=new"])
|
||||
context = browser.new_context()
|
||||
admin_user = context.new_page()
|
||||
|
||||
browser_two = browser_type.launch(headless=True)
|
||||
|
||||
if browser_name == "firefox":
|
||||
browser_two = playwright.firefox.launch(headless=True)
|
||||
else:
|
||||
# this leverages new headless mode by Chromium: https://developer.chrome.com/articles/new-headless/
|
||||
# The mode is however ~40% slower: https://github.com/microsoft/playwright/issues/21216
|
||||
browser_two = playwright.chromium.launch(headless=False,args=["--headless=new"])
|
||||
context_two = browser_two.new_context()
|
||||
docs_user = context_two.new_page()
|
||||
|
||||
|
|
|
@ -11,10 +11,11 @@ def main(browser_name: str = "chromium"):
|
|||
with sync_playwright() as playwright:
|
||||
log_note(f"Launch browser {browser_name}")
|
||||
if browser_name == "firefox":
|
||||
browser_type = playwright.firefox
|
||||
browser = playwright.firefox.launch(headless=True)
|
||||
else:
|
||||
browser_type = playwright.chromium
|
||||
browser = browser_type.launch(headless=True)
|
||||
# this leverages new headless mode by Chromium: https://developer.chrome.com/articles/new-headless/
|
||||
# The mode is however ~40% slower: https://github.com/microsoft/playwright/issues/21216
|
||||
browser = playwright.chromium.launch(headless=False,args=["--headless=new"])
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
try:
|
||||
|
|
|
@ -23,12 +23,13 @@ def send_message(sender, message):
|
|||
log_note("GMT_SCI_R=1")
|
||||
|
||||
def create_conversation(playwright: Playwright, browser_name: str) -> str:
|
||||
headless = True
|
||||
log_note(f"Launch browser {browser_name}")
|
||||
if browser_name == "firefox":
|
||||
browser = playwright.firefox.launch(headless=headless)
|
||||
browser = playwright.firefox.launch(headless=True)
|
||||
else:
|
||||
browser = playwright.chromium.launch(headless=headless)
|
||||
# this leverages new headless mode by Chromium: https://developer.chrome.com/articles/new-headless/
|
||||
# The mode is however ~40% slower: https://github.com/microsoft/playwright/issues/21216
|
||||
browser = playwright.chromium.launch(headless=False,args=["--headless=new"])
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
try:
|
||||
|
@ -55,14 +56,13 @@ def create_conversation(playwright: Playwright, browser_name: str) -> str:
|
|||
page.get_by_role("button", name="Close modal").click(timeout=15_000)
|
||||
|
||||
# Headless browsers trigger a warning in Nextcloud, however they actually work fine
|
||||
if headless:
|
||||
log_note("Close headless warning")
|
||||
with contextlib.suppress(Exception):
|
||||
page.wait_for_selector('.toast-close')
|
||||
page.click('.toast-close')
|
||||
log_note("Close headless warning")
|
||||
with contextlib.suppress(Exception):
|
||||
page.wait_for_selector('.toast-close')
|
||||
page.click('.toast-close')
|
||||
|
||||
page.wait_for_selector('.toast-close')
|
||||
page.click('.toast-close')
|
||||
page.wait_for_selector('.toast-close')
|
||||
page.click('.toast-close')
|
||||
|
||||
log_note("Create conversation")
|
||||
page.get_by_role("button", name="Create a new group conversation").click()
|
||||
|
@ -86,16 +86,17 @@ def create_conversation(playwright: Playwright, browser_name: str) -> str:
|
|||
raise e
|
||||
|
||||
def talk(playwright: Playwright, url: str, browser_name: str) -> None:
|
||||
headless = True
|
||||
action_delay_ms = 300
|
||||
browser_count = 5
|
||||
|
||||
# Launch browsers
|
||||
log_note(f"Launching {browser_count} {browser_name} browsers")
|
||||
if browser_name == "firefox":
|
||||
browsers = [playwright.firefox.launch(headless=headless, slow_mo=action_delay_ms) for _ in range(browser_count)]
|
||||
browsers = [playwright.firefox.launch(headless=False, slow_mo=action_delay_ms) for _ in range(browser_count)]
|
||||
else:
|
||||
browsers = [playwright.chromium.launch(headless=headless, slow_mo=action_delay_ms) for _ in range(browser_count)]
|
||||
# this leverages new headless mode by Chromium: https://developer.chrome.com/articles/new-headless/
|
||||
# The mode is however ~40% slower: https://github.com/microsoft/playwright/issues/21216
|
||||
browsers = [playwright.chromium.launch(headless=False,args=["--headless=new"], slow_mo=action_delay_ms) for _ in range(browser_count)]
|
||||
contexts = [browser.new_context() for browser in browsers]
|
||||
pages = [context.new_page() for context in contexts]
|
||||
|
||||
|
@ -105,11 +106,10 @@ def talk(playwright: Playwright, url: str, browser_name: str) -> None:
|
|||
page.goto(url)
|
||||
|
||||
# Close toast messages for headless browsers
|
||||
if headless:
|
||||
log_note("Close headless warning")
|
||||
with contextlib.suppress(Exception):
|
||||
for page in pages:
|
||||
page.wait_for_selector('.toast-close').click()
|
||||
log_note("Close headless warning")
|
||||
with contextlib.suppress(Exception):
|
||||
for page in pages:
|
||||
page.wait_for_selector('.toast-close').click()
|
||||
|
||||
# Perform actions for all users
|
||||
log_note("Set guest usernames")
|
||||
|
|
Loading…
Add table
Reference in a new issue