Skip to content

Commit 475a177

Browse files
committed
Moved Wordpress example to Playwright
1 parent a3bbab1 commit 475a177

File tree

3 files changed

+42
-48
lines changed

3 files changed

+42
-48
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from time import time_ns
2+
from playwright.sync_api import sync_playwright
3+
4+
def log_note(message: str) -> None:
5+
timestamp = str(time_ns())[:16]
6+
print(f"{timestamp} {message}")
7+
8+
with sync_playwright() as playwright:
9+
log_note('Launching browser')
10+
11+
browser = playwright.chromium.launch(headless=True)
12+
context = browser.new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
13+
page = context.new_page()
14+
15+
dimensions = page.evaluate("""
16+
() => {
17+
return {
18+
width: document.documentElement.clientWidth,
19+
height: document.documentElement.clientHeight,
20+
deviceScaleFactor: window.devicePixelRatio,
21+
}
22+
}
23+
""")
24+
# print("Dimensions:", dimensions) # Optional check
25+
26+
log_note('Home Page')
27+
page.goto("http://gcb-wordpress:9875", wait_until="networkidle")
28+
29+
# Wait until logo is visible
30+
page.locator('p#logo').wait_for(timeout=30)
31+
32+
33+
# Example of navigating to another page:
34+
# page.goto("http://gcb-wordpress:9875/my-sample-page", wait_until="networkidle")
35+
36+
log_note('Closing browser')
37+
browser.close()

wordpress-official-starter/puppeteer-flow.js

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
---
2-
name: Wordpress Basic Puppeteer Scenario
3-
author: Arne Tarara <arne@green-coding.berlin>
2+
name: Wordpress Basic Playwright Scenario
3+
author: Arne Tarara <arne@green-coding.io>
44
description: Simple Wordpress where just the Homepage with the install instructions is accessed. Mostly used for testing wordpress build and startup times.
55
compose-file: !include compose.yml
66

77
services:
88
gcb-puppeteer:
9-
image: greencoding/puppeteer-chrome
10-
setup-commands:
11-
- cp /tmp/repo/wordpress-official-starter/puppeteer-flow.js /var/www/puppeteer-flow.js
9+
image: greencoding/gcb_playwright:v16
1210
networks:
1311
- gcb-mariadb-wordpress-network
1412

@@ -17,10 +15,8 @@ flow:
1715
container: gcb-puppeteer
1816
commands:
1917
- type: console
20-
command: node /var/www/puppeteer-flow.js
21-
note: Starting Puppeteer Flow
18+
command: python3 /tmp/repo/wordpress-official-starter/playwright-flow.py
19+
note: Starting User Journey
2220
read-notes-stdout: true
2321
log-stdout: true
2422
log-stderr: true
25-
26-

0 commit comments

Comments
 (0)