Пожалуйста, помогите мне.
Я пытаюсь создать скрипт Python для входа на icloud.com. Не могу найти элемент, отвечающий за поле электронной почты.
Как обеспечить обнаружение поля ввода после нажатия кнопки входа?
Есть ли в Playwright конкретные методы обработки динамического контента или элементов iframe, которые мне могут не хватать?
from playwright.sync_api import sync_playwright
input_selector = "input#account_name_text_field"
with sync_playwright() as p:
browser = p.firefox.launch(headless=False)
page = browser.new_page()
page.goto("https://www.icloud.com/")
page.wait_for_load_state("load")
print("Page loaded")
try:
page.click(".sign-in-button")
print("Login button clicked")
page.wait_for_timeout(5000) # Wait 5 seconds after clicking the login button
print("Waited 5 seconds after clicking the login button.")
# Check if the page contains iframes
iframes = page.query_selector_all("iframe")
print(f"Found {len(iframes)} iframe(s) on the page.")
if len(iframes) > 0:
for i, iframe in enumerate(iframes):
print(f"Checking iframe {i + 1}")
iframe_page = iframe.content_frame()
input_field = iframe_page.query_selector(input_selector)
if input_field:
print(f"Found input field in iframe {i + 1}.")
input_field.fill("[email protected]")
print("Filled the email field in the iframe.")
break
else:
print("Did not find input field in any iframe.")
else:
print("No iframes found on the page.")
input_field = page.query_selector(input_selector)
if input_field:
input_field.fill("[email protected]")
print("Filled the email field on the page.")
except Exception as e:
print(f"Error: {e}")
browser.close()```
Подробнее здесь: https://stackoverflow.com/questions/792 ... -playwrigh
Проблема: невозможно найти поле после нажатия кнопки входа в систему в Playwright. ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение