0
0
Fork 0
mirror of https://github.com/nextcloud/docker.git synced 2025-03-14 18:35:08 +01:00
This commit is contained in:
Danilo Ješić 2023-06-09 10:49:49 +02:00
parent 089a3f196f
commit bedeec0605
5 changed files with 10 additions and 111 deletions

View file

@ -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())

View file

@ -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)

View file

@ -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()

View file

@ -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()

View file

@ -1,8 +1,8 @@
---
name: NextCloud MariaDB
author: Didi Hoffmann <didi@green-coding.berlin>
name: NextCloud MariaDB - Chrome Talk
author: Danilo Jesic <danilo@green-coding.berlin>
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