diff --git a/nextcloud_create_event_playwright.py b/nextcloud_create_event_playwright.py deleted file mode 100644 index 9aaa55a1..00000000 --- a/nextcloud_create_event_playwright.py +++ /dev/null @@ -1,64 +0,0 @@ -import asyncio -import time -from playwright.async_api import async_playwright - -async def main(): - async with async_playwright() as playwright: - browser_type = playwright.chromium - browser = await browser_type.launch(headless=True, args=["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"]) - page = await browser.new_page() - # await page.set_default_timeout(60_000) # milliseconds - await page.goto('http://app/login') - - # 1. Login - user_element = await page.wait_for_selector('//*[@data-login-form-input-user]') - await user_element.type('Crash') - pass_element = await page.wait_for_selector('//*[@data-login-form-input-password]') - await pass_element.type('Override') - await page.click('.button-vue--vue-primary') - print(time.time(), "Login clicked") - - # Handle unsupported browsers warning - unsupported_element = await page.wait_for_selector('.content-unsupported-browser__continue') - if unsupported_element: - await unsupported_element.click() - print(time.time(), "Unsupported browsers warning clicked") - - await page.wait_for_navigation(wait_until='domcontentloaded', url='http://app/apps/dashboard/') - - # Wait for the modal to load and close - await asyncio.sleep(3) - - # 2. Close Modal - modal_close = await page.wait_for_selector('.modal-container__close') - await modal_close.click() - print(time.time(), "Intro video modal clicked") - - # Wait for the modal animation to complete - await asyncio.sleep(3) - - # 3. Go to Cal - await page.click('a[href="/apps/calendar/"]') - print(time.time(), "Calendar clicked") - - # 4. Open New Event Box - new_event_selector = await page.wait_for_selector('.new-event') - await new_event_selector.click() - print(time.time(), "New event clicked") - - # 4. Create Event - title_selector = await page.wait_for_selector('input[placeholder="Event title"]') - await title_selector.type('NYC2600 Meeting') - save_selector = await page.wait_for_selector('text=Save') - await save_selector.click() - print(time.time(), "Save event clicked") - - # 5. Wait for the event - await page.wait_for_selector('text=NYC2600 Meeting') - print(time.time(), "Event found! Fin") - - await browser.close() - - -if __name__ == '__main__': - asyncio.run(main()) diff --git a/nextcloud_create_user_playwright.py b/nextcloud_create_user_playwright.py deleted file mode 100644 index 4ec70657..00000000 --- a/nextcloud_create_user_playwright.py +++ /dev/null @@ -1,31 +0,0 @@ -from playwright.sync_api import Playwright, sync_playwright - - -def run(playwright: Playwright) -> None: - browser = playwright.chromium.launch(headless=False) - context = browser.new_context() - page = context.new_page() - page.goto("http://localhost:8080/login") - page.get_by_label("Account name or email").click() - page.get_by_label("Account name or email").fill("Crash") - page.get_by_label("Password", exact=True).click() - page.get_by_label("Password", exact=True).fill("Override") - page.get_by_role("button", name="Log in").click() - page.get_by_role("link", name="Open settings menu").click() - page.get_by_role("link", name="Users").click() - page.get_by_role("button", name="New user").click() - page.get_by_placeholder("Username").click() - page.get_by_placeholder("Username").fill("Splash") - page.get_by_placeholder("Display name").click() - page.get_by_placeholder("Display name").fill("Splash") - page.get_by_placeholder("Password", exact=True).click() - page.get_by_placeholder("Password", exact=True).fill("cymbals3533") - page.get_by_role("button", name="Add a new user").click() - - # --------------------- - context.close() - browser.close() - - -with sync_playwright() as playwright: - run(playwright) diff --git a/nextcloud_install_playwright.py b/nextcloud_install_playwright.py index dd1b5ae2..50884080 100644 --- a/nextcloud_install_playwright.py +++ b/nextcloud_install_playwright.py @@ -9,7 +9,7 @@ def main(): args=["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"] ) page = browser.new_page() - page.goto('http://localhost:8080/') + page.goto('http://nc/') page.set_default_timeout(120_000) # 1. Create User @@ -27,7 +27,6 @@ def main(): # 3. Dashboard page.wait_for_selector('.app-dashboard') print(time(), "Dashboard found") - page.get_by_role("button", name="Close modal").click() browser.close() diff --git a/nextcloud_talk_playwright.py b/nextcloud_talk_playwright.py index 7d214ef9..15ce61b5 100644 --- a/nextcloud_talk_playwright.py +++ b/nextcloud_talk_playwright.py @@ -2,10 +2,10 @@ from playwright.sync_api import Playwright, sync_playwright def create_conversation(playwright: Playwright) -> str: - browser = playwright.chromium.launch(headless=False) + browser = playwright.chromium.launch(headless=True) context = browser.new_context() page = context.new_page() - page.goto("http://localhost:8080/login") + page.goto("http://nc/login") page.get_by_label("Account name or email").click() page.get_by_label("Account name or email").fill("Crash") page.get_by_label("Account name or email").press("Tab") @@ -30,8 +30,8 @@ def create_conversation(playwright: Playwright) -> str: return page.url def talk(playwright: Playwright, url: str) -> None: - browser_one = playwright.chromium.launch(headless=False, slow_mo=1500) - browser_two = playwright.chromium.launch(headless=False, slow_mo=1500) + browser_one = playwright.chromium.launch(headless=True, slow_mo=1500) + browser_two = playwright.chromium.launch(headless=True, slow_mo=1500) context_one = browser_one.new_context() context_two = browser_two.new_context() user_one = context_one.new_page() diff --git a/usage_scenario.yml b/usage_scenario.yml index dff4424f..d68dd9de 100644 --- a/usage_scenario.yml +++ b/usage_scenario.yml @@ -1,8 +1,8 @@ --- -name: NextCloud MariaDB -author: Didi Hoffmann +name: NextCloud MariaDB - Chrome Talk +author: Danilo Jesic version: 1 -description: Installs the official NextCloud image and creates an user and event +description: Installs the official NextCloud image and creates a user and starts a Talk conversation compose-file: !include compose.yml services: @@ -13,12 +13,7 @@ services: dockerfile: Dockerfile setup-commands: - cp /tmp/repo/nextcloud/chrome/apache_mariadb/nextcloud_install_playwright.py /tmp/nextcloud_install_playwright.py - - cp /tmp/repo/nextcloud/chrome/apache_mariadb/nextcloud_create_event_playwright.py /tmp/nextcloud_create_event_playwright.py - # gcb-puppeteer: - # image: greencoding/puppeteer-chrome - # setup-commands: - # - cp /tmp/repo/nextcloud/chrome/apache_mariadb/nextcloud_install_puppeteer.js /var/www/nextcloud_install_puppeteer.js - # - cp /tmp/repo/nextcloud/chrome/apache_mariadb/nextcloud_create_event_puppeteer.js /var/www/nextcloud_create_event_puppeteer.js + - cp /tmp/repo/nextcloud/chrome/apache_mariadb/nextcloud_talk_playwright.py /tmp/nextcloud_talk_playwright.py networks: - nextcloud-setup-network @@ -50,6 +45,6 @@ flow: note: Installing Nextcloud read-notes-stdout: true - type: console - command: python3 /tmp/nextcloud_create_event_playwright.py + command: python3 /tmp/nextcloud_talk_playwright.py note: Creating Event read-notes-stdout: true