Skip to content

Commit 9066cc0

Browse files
experiment and test lock file
1 parent fbff5d6 commit 9066cc0

File tree

2 files changed

+8422
-0
lines changed

2 files changed

+8422
-0
lines changed

experiments/react-playwright.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from playwright.sync_api import sync_playwright
2+
import subprocess
3+
import sys
4+
5+
6+
def ensure_browser_installed():
7+
try:
8+
with sync_playwright() as p:
9+
p.chromium.launch(headless=True)
10+
except Exception:
11+
subprocess.run(
12+
[sys.executable, "-m", "playwright", "install", "chromium"],
13+
check=True
14+
)
15+
16+
17+
ensure_browser_installed()
18+
19+
with sync_playwright() as p:
20+
browser = p.chromium.launch(headless=True)
21+
page = browser.new_page()
22+
23+
page.set_content("""
24+
<div id="root"></div>
25+
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
26+
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
27+
<script>
28+
const root = ReactDOM.createRoot(document.getElementById('root'));
29+
root.render(React.createElement("h1", null, "Hello from React"));
30+
</script>
31+
""")
32+
33+
print(page.content())

0 commit comments

Comments
 (0)