-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_closed_testing.py
More file actions
287 lines (241 loc) · 9.92 KB
/
setup_closed_testing.py
File metadata and controls
287 lines (241 loc) · 9.92 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#!/usr/bin/env python3
"""Set up Closed Testing track with 20 testers in Google Play Console."""
import time
from pathlib import Path
from playwright.sync_api import sync_playwright
from play_artifacts import ARTIFACTS_DIR, screenshot_path
DEV = "8239620436488925047"
APP = "4976249162120849673"
BASE = f"https://play.google.com/console/u/0/developers/{DEV}/app/{APP}"
TESTERS = "\n".join([f"ig5973700+tester{i}@gmail.com" for i in range(1, 21)])
REPO_ROOT = Path(__file__).resolve().parent.parent
AAB_PATH = REPO_ROOT / "native-android" / "app" / "build" / "outputs" / "bundle" / "release" / "app-release.aab"
def screenshot(page, name):
path = screenshot_path(f"play_{name}.png")
page.screenshot(path=path, full_page=True)
print(f" Screenshot: {path}")
def click_text(page, text, timeout=5000):
try:
loc = page.get_by_text(text, exact=False).first
loc.wait_for(state="visible", timeout=timeout)
loc.scroll_into_view_if_needed()
time.sleep(0.3)
loc.click()
time.sleep(2)
return True
except:
return False
def click_button(page, name, timeout=5000):
try:
loc = page.get_by_role("button", name=name).first
loc.wait_for(state="visible", timeout=timeout)
loc.scroll_into_view_if_needed()
loc.click()
time.sleep(2)
return True
except:
return False
def click_link(page, name, timeout=5000):
try:
loc = page.get_by_role("link", name=name).first
loc.wait_for(state="visible", timeout=timeout)
loc.click()
time.sleep(2)
return True
except:
return False
def js_fill_textarea(page, text, index=0):
return page.evaluate("""
(args) => {
const textareas = document.querySelectorAll('textarea');
if (textareas.length > args.index) {
const ta = textareas[args.index];
ta.focus();
const nativeSetter = Object.getOwnPropertyDescriptor(
window.HTMLTextAreaElement.prototype, 'value'
).set;
nativeSetter.call(ta, args.text);
ta.dispatchEvent(new Event('input', { bubbles: true }));
ta.dispatchEvent(new Event('change', { bubbles: true }));
ta.dispatchEvent(new Event('blur', { bubbles: true }));
return true;
}
return false;
}
""", {"text": text, "index": index})
def main():
with sync_playwright() as p:
print("Connecting to Chrome on port 9222...")
browser = p.chromium.connect_over_cdp("http://localhost:9222")
context = browser.contexts[0]
play_page = None
for pg in context.pages:
if "play.google.com/console" in pg.url:
play_page = pg
break
if not play_page:
play_page = context.new_page()
page = play_page
# Step 1: Navigate to Closed Testing
print("\n=== Step 1: Navigate to Closed Testing ===")
closed_url = f"{BASE}/tracks/closed-testing"
page.goto(closed_url, wait_until="networkidle", timeout=60000)
time.sleep(5)
screenshot(page, "closed_01_nav")
print(f" URL: {page.url}")
# If redirected, try sidebar navigation
if "closed" not in page.url.lower() and "track" not in page.url.lower():
print(" Direct URL didn't work, trying sidebar...")
# Try going to app dashboard first
page.goto(f"{BASE}/app-dashboard", wait_until="networkidle", timeout=60000)
time.sleep(5)
# Click Testing in sidebar
if not click_text(page, "Testing"):
click_text(page, "Release")
time.sleep(2)
# Click Closed testing
if not click_text(page, "Closed testing"):
click_text(page, "Closed")
time.sleep(3)
screenshot(page, "closed_02_sidebar")
print(f" URL: {page.url}")
# Step 2: Create a new closed testing track (if needed)
print("\n=== Step 2: Create Closed Testing Track ===")
screenshot(page, "closed_03_page")
# Look for "Create track" or "Create new release" button
created = False
for btn_text in ["Create track", "Create new track", "Create closed track"]:
if click_button(page, btn_text):
print(f" Clicked '{btn_text}'")
created = True
break
if not created:
# Maybe track already exists, look for "Create new release"
for btn_text in ["Create new release", "Create release"]:
if click_button(page, btn_text):
print(f" Clicked '{btn_text}'")
created = True
break
time.sleep(3)
screenshot(page, "closed_04_track")
print(f" URL: {page.url}")
# Step 3: Upload AAB
print("\n=== Step 3: Upload AAB ===")
# Look for file upload input
try:
file_input = page.locator("input[type='file']").first
file_input.set_input_files(AAB_PATH)
print(f" Uploaded AAB: {AAB_PATH}")
# Wait for upload to complete
time.sleep(30)
screenshot(page, "closed_05_aab_uploaded")
except Exception as e:
print(f" File input not found, trying 'Upload' button: {e}")
if click_button(page, "Upload"):
time.sleep(2)
try:
file_input = page.locator("input[type='file']").first
file_input.set_input_files(AAB_PATH)
print(f" Uploaded AAB via button")
time.sleep(30)
except Exception as e2:
print(f" Upload failed: {e2}")
screenshot(page, "closed_05_upload_attempt")
# Step 4: Fill release notes if needed
print("\n=== Step 4: Release Notes ===")
release_notes = "Initial release of Random Timer - a fun productivity app that generates random countdown timers."
filled = js_fill_textarea(page, release_notes, 0)
if filled:
print(" Filled release notes")
else:
# Try clicking "Add release notes" first
click_text(page, "Add release notes")
time.sleep(2)
js_fill_textarea(page, release_notes, 0)
screenshot(page, "closed_06_notes")
# Step 5: Save / Review release
print("\n=== Step 5: Save Release ===")
for btn in ["Save", "Review release", "Next", "Save and publish"]:
if click_button(page, btn):
print(f" Clicked '{btn}'")
time.sleep(3)
break
screenshot(page, "closed_07_saved")
# Step 6: Set up testers list
print("\n=== Step 6: Add Testers ===")
# Navigate to testers management
# Try clicking "Manage track" or "Testers" tab
click_text(page, "Testers")
time.sleep(2)
if not click_text(page, "Manage testers"):
click_text(page, "Create email list")
time.sleep(3)
screenshot(page, "closed_08_testers")
# Try to find email list creation
if click_button(page, "Create email list"):
time.sleep(2)
# Fill list name
try:
name_input = page.locator("input[type='text']").first
name_input.fill("Beta Testers")
time.sleep(1)
except:
js_fill_textarea(page, "Beta Testers", 0)
# Add email addresses
print(" Adding 20 tester emails...")
# Try textarea for bulk email entry
filled = False
for i in range(5):
if js_fill_textarea(page, TESTERS, i):
print(f" Filled emails in textarea index {i}")
filled = True
break
if not filled:
# Try comma-separated in input
comma_testers = ", ".join([f"ig5973700+tester{i}@gmail.com" for i in range(1, 21)])
for i in range(5):
try:
inputs = page.locator("input[type='text']").all()
if len(inputs) > i:
inputs[i].fill(comma_testers)
print(f" Filled emails in input index {i}")
filled = True
break
except:
pass
screenshot(page, "closed_09_emails")
# Save testers
for btn in ["Save changes", "Save", "Create", "Done", "Add"]:
if click_button(page, btn):
print(f" Clicked '{btn}'")
time.sleep(2)
break
screenshot(page, "closed_10_saved_testers")
# Step 7: Start rollout / publish to closed testing
print("\n=== Step 7: Publish to Closed Testing ===")
for btn in ["Start rollout", "Roll out", "Publish", "Start roll-out to Closed testing",
"Send for review", "Submit for review"]:
if click_button(page, btn):
print(f" Clicked '{btn}'")
time.sleep(2)
# Confirm dialog
click_button(page, "Roll out")
click_button(page, "Confirm")
click_button(page, "Yes")
break
time.sleep(3)
screenshot(page, "closed_11_published")
# Final status check
print("\n=== Final Status ===")
print(f" URL: {page.url}")
screenshot(page, "closed_12_final")
body = page.locator("body").text_content()
if "review" in body.lower():
print(" App appears to be in review!")
if "closed testing" in body.lower():
print(" Closed testing track is set up")
print("\n=== DONE ===")
print(f"Check {ARTIFACTS_DIR} for screenshots of each step.")
print("Browser left open for manual verification.")
if __name__ == "__main__":
main()