feature/gemini-web-provider #1
|
|
@ -393,10 +393,61 @@ func (p *PlaywrightProvider) typeInput(text string) error {
|
|||
}
|
||||
|
||||
if !found {
|
||||
// 顯示 debug 信息
|
||||
// 保存診斷信息
|
||||
screenshotPath := "/tmp/gemini-debug.png"
|
||||
htmlPath := "/tmp/gemini-debug.html"
|
||||
|
||||
// 截圖
|
||||
if _, err := p.page.Screenshot(playwright.PageScreenshotOptions{
|
||||
Path: playwright.String(screenshotPath),
|
||||
}); err == nil {
|
||||
fmt.Printf("[GeminiWeb] Screenshot saved: %s\n", screenshotPath)
|
||||
}
|
||||
|
||||
// HTML
|
||||
if html, err := p.page.Content(); err == nil {
|
||||
if err := os.WriteFile(htmlPath, []byte(html), 0644); err == nil {
|
||||
fmt.Printf("[GeminiWeb] HTML saved: %s\n", htmlPath)
|
||||
}
|
||||
}
|
||||
|
||||
// 輸出調試信息
|
||||
url := p.page.URL()
|
||||
title, _ := p.page.Title()
|
||||
return fmt.Errorf("input field not found (URL=%s, Title=%s)", url, title)
|
||||
fmt.Printf("[GeminiWeb] DEBUG: URL=%s\n", url)
|
||||
fmt.Printf("[GeminiWeb] DEBUG: Title=%s\n", title)
|
||||
|
||||
// 嘗試用 JavaScript 找輸入框
|
||||
fmt.Println("[GeminiWeb] Trying JavaScript element search...")
|
||||
_, _ = p.page.Evaluate(`
|
||||
() => {
|
||||
console.log('=== DEBUG: Looking for input elements ===');
|
||||
const selectors = [
|
||||
'.ProseMirror',
|
||||
'rich-textarea',
|
||||
'div[role="textbox"]',
|
||||
'div[contenteditable="true"]',
|
||||
'textarea',
|
||||
'input'
|
||||
];
|
||||
for (const sel of selectors) {
|
||||
const els = document.querySelectorAll(sel);
|
||||
if (els.length > 0) {
|
||||
console.log('Found', els.length, 'elements for:', sel);
|
||||
}
|
||||
}
|
||||
|
||||
// 檢查頁面中所有可交互元素
|
||||
const interactable = document.querySelectorAll('div[contenteditable="true"], textarea, input[type="text"], [role="textbox"]');
|
||||
console.log('Total interactable elements:', interactable.length);
|
||||
|
||||
return { found: false };
|
||||
}
|
||||
`)
|
||||
|
||||
// 顯示最後的URL和標題
|
||||
return fmt.Errorf("input field not found (URL=%s, Title=%s). Screenshot saved to %s, HTML saved to %s",
|
||||
url, title, screenshotPath, htmlPath)
|
||||
}
|
||||
|
||||
// Focus 並填充(Playwright 自動等待)
|
||||
|
|
|
|||
Loading…
Reference in New Issue