2023-06-16 17:14:22 +02:00
|
|
|
from time import time_ns
|
|
|
|
|
2023-06-09 10:43:34 +02:00
|
|
|
from playwright.sync_api import sync_playwright
|
2023-06-06 15:10:14 +02:00
|
|
|
|
2023-06-16 17:14:22 +02:00
|
|
|
def log_note(message: str) -> None:
|
2023-06-16 17:23:52 +02:00
|
|
|
timestamp = str(time_ns())[:16]
|
2023-06-16 17:14:22 +02:00
|
|
|
print(f"{timestamp} {message}")
|
|
|
|
|
2023-06-09 10:43:34 +02:00
|
|
|
def main():
|
|
|
|
with sync_playwright() as playwright:
|
2023-06-16 17:14:22 +02:00
|
|
|
log_note("Launch browser")
|
2023-06-06 15:10:14 +02:00
|
|
|
browser_type = playwright.chromium
|
2023-06-09 10:43:34 +02:00
|
|
|
browser = browser_type.launch(
|
2023-06-09 11:43:58 +02:00
|
|
|
headless=True,
|
2023-06-06 15:10:14 +02:00
|
|
|
args=["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"]
|
|
|
|
)
|
2023-06-09 10:43:34 +02:00
|
|
|
page = browser.new_page()
|
2023-06-09 10:49:49 +02:00
|
|
|
page.goto('http://nc/')
|
2023-06-09 14:41:11 +02:00
|
|
|
page.set_default_timeout(180_000)
|
2023-06-06 15:10:14 +02:00
|
|
|
|
|
|
|
# 1. Create User
|
2023-06-16 17:14:22 +02:00
|
|
|
log_note("Create admin user")
|
2023-06-09 10:43:34 +02:00
|
|
|
page.type('#adminlogin', 'Crash')
|
|
|
|
page.type('#adminpass', 'Override')
|
|
|
|
page.click('.primary')
|
2023-06-06 15:10:14 +02:00
|
|
|
|
|
|
|
# 2. Install all Apps
|
2023-06-16 17:14:22 +02:00
|
|
|
log_note("Install recommended apps")
|
2023-06-06 15:10:14 +02:00
|
|
|
install_selector = '.button-vue--vue-primary'
|
2023-06-16 15:44:04 +02:00
|
|
|
page.wait_for_selector(install_selector)
|
2023-06-09 10:43:34 +02:00
|
|
|
page.click(install_selector)
|
2023-06-06 15:10:14 +02:00
|
|
|
|
|
|
|
# 3. Dashboard
|
2023-06-09 10:43:34 +02:00
|
|
|
page.wait_for_selector('.app-dashboard')
|
2023-06-16 17:14:22 +02:00
|
|
|
log_note("Installation complete")
|
2023-06-06 15:10:14 +02:00
|
|
|
|
2023-06-09 10:43:34 +02:00
|
|
|
browser.close()
|
2023-06-06 15:10:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2023-06-09 10:43:34 +02:00
|
|
|
main()
|