mirror of
https://github.com/nextcloud/docker.git
synced 2025-03-15 19:05:09 +01:00
Playwright scripts first draft
This commit is contained in:
parent
22d28e45cd
commit
86a442638d
4 changed files with 149 additions and 0 deletions
16
Dockerfile
Normal file
16
Dockerfile
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
FROM python:3.11
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
curl \
|
||||||
|
wget \
|
||||||
|
gnupg \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install Playwright
|
||||||
|
RUN pip install playwright
|
||||||
|
|
||||||
|
# Set up Playwright dependencies for Chromium, Firefox and Webkit
|
||||||
|
RUN playwright install
|
||||||
|
|
||||||
|
CMD ["/bin/bash"]
|
33
compose.yml
Normal file
33
compose.yml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
version: '2'
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
nextcloud:
|
||||||
|
db:
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: mariadb:10.6
|
||||||
|
restart: always
|
||||||
|
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
|
||||||
|
volumes:
|
||||||
|
- db:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=TheGibson
|
||||||
|
- MYSQL_PASSWORD=TheGibson
|
||||||
|
- MYSQL_DATABASE=nextcloud
|
||||||
|
- MYSQL_USER=nextcloud
|
||||||
|
|
||||||
|
app:
|
||||||
|
image: nextcloud:26.0.1
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
links:
|
||||||
|
- db
|
||||||
|
volumes:
|
||||||
|
- nextcloud:/var/www/html
|
||||||
|
environment:
|
||||||
|
- MYSQL_PASSWORD=TheGibson
|
||||||
|
- MYSQL_DATABASE=nextcloud
|
||||||
|
- MYSQL_USER=nextcloud
|
||||||
|
- MYSQL_HOST=db
|
64
nextcloud_create_event_playwright.py
Normal file
64
nextcloud_create_event_playwright.py
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
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())
|
36
nextcloud_install_playwright.py
Normal file
36
nextcloud_install_playwright.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
from playwright.async_api import async_playwright
|
||||||
|
from time import time
|
||||||
|
|
||||||
|
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/')
|
||||||
|
|
||||||
|
# 1. Create User
|
||||||
|
await page.type('#adminlogin', 'Crash')
|
||||||
|
await page.type('#adminpass', 'Override')
|
||||||
|
await page.click('.primary')
|
||||||
|
print(time(), "Create user clicked")
|
||||||
|
|
||||||
|
# 2. Install all Apps
|
||||||
|
install_selector = '.button-vue--vue-primary'
|
||||||
|
await page.wait_for_selector(install_selector)
|
||||||
|
await page.click(install_selector)
|
||||||
|
print(time(), "Install apps clicked")
|
||||||
|
|
||||||
|
# 3. Dashboard
|
||||||
|
await page.wait_for_selector('.app-dashboard')
|
||||||
|
print(time(), "Dashboard found")
|
||||||
|
|
||||||
|
await browser.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import asyncio
|
||||||
|
asyncio.run(main())
|
Loading…
Add table
Reference in a new issue