-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfluence.py
More file actions
74 lines (60 loc) · 2.88 KB
/
Copy pathconfluence.py
File metadata and controls
74 lines (60 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
# ---------------------------------------------------------------------------
# Driver setup — webdriver-manager handles ChromeDriver version matching
# ---------------------------------------------------------------------------
options = Options()
options.add_argument("--incognito")
# options.add_argument("--headless") # uncomment for CI/headless environments
service = Service(ChromeDriverManager().install())
browser = webdriver.Chrome(service=service, options=options)
# ---------------------------------------------------------------------------
# Configuration — all values sourced from environment variables
# ---------------------------------------------------------------------------
CONFLUENCE_URL = os.environ.get("CONFLUENCE_BLOG_URL", "https://example.atlassian.net")
browser.get(CONFLUENCE_URL)
print("Title: %s" % browser.title)
# ---------------------------------------------------------------------------
# Authentication
# ---------------------------------------------------------------------------
Wait = WebDriverWait(browser, 10)
email_field = Wait.until(EC.presence_of_element_located((By.ID, "username")))
email_field.send_keys(os.environ.get("MY_APP_EMAIL", ""))
browser.find_element(By.ID, "login-submit").click()
Wait.until(EC.presence_of_element_located((By.ID, "password")))
browser.find_element(By.ID, "password").send_keys(os.environ.get("MY_APP_KEY", ""))
browser.find_element(By.ID, "login-submit").click()
# ---------------------------------------------------------------------------
# Wait for landing page
# ---------------------------------------------------------------------------
Wait.until(EC.presence_of_element_located((By.ID, "createGlobalItem")))
# ---------------------------------------------------------------------------
# Create a new blog post
# ---------------------------------------------------------------------------
browser.find_element(By.ID, "createGlobalItem").click()
Wait.until(EC.presence_of_element_located((By.CLASS_NAME, "atlaskit-portal")))
# Page title
title_field = Wait.until(
EC.presence_of_element_located(
(By.CSS_SELECTOR, "textarea[data-test-id='editor-title']")
)
)
title_field.click()
title_field.send_keys("Sample Title")
# Page content
content_area = Wait.until(
EC.presence_of_element_located(
(By.CSS_SELECTOR, "div.ProseMirror[aria-label='Main content area']")
)
)
content_area.click()
content_area.send_keys("Sample content here.")
# Publish — uncomment when ready
# browser.find_element(By.ID, "publish-button").click()
# browser.quit()