[英]How do you enter text into a Flash TextArea from Puppeteer?
我正在嘗試通過 Puppeteer 自動登錄 Flash object。 我只需單擊即可自動關注 Flash TextArea,這似乎有效(顯示您正在輸入的垂直閃爍條出現)。 但是,我嘗試使用page.keyboard.press
、 page.keyboard.up
/ page.keyboard.down
和page.keyboard.type
,但沒有一個成功在用戶名或密碼字段中輸入文本。 Furthermore, I have set a piece of injected Javascript to console.log
the key name of every keypress
event on the Flash object, and it only fires when I am manually typing while focused on the Flash object. 在我嘗試使用 Puppeteer 鍵盤輸入時,它沒有記錄任何內容。 我的代碼如下:
const login = async (page) => {
await page.waitFor(20);
const username = process.env.SIGNIN_USERNAME;
await page.click(500,500); // Select the username field
await page.waitFor(20); // Allow the blinking bar to appear
await page.keyboard.type(username);
for(let char of username) {
await page.keyboard.press(char);
await page.waitFor(20); // So that it appears like a user is typing
}
for(let char of username){
await page.keyboard.down(char);
await page.waitFor(10);
await page.keyboard.up(char);
await page.waitFor(20);
}
await page.type("object",username); // The Flash object is the first object on the page
console.log(username) // The username is logged to the console and is defined
};
此代碼不會導致 Flash TextArea 中出現任何文本。 但是,正確的用戶名會記錄到控制台。
我是否犯了一個錯誤,或者在 Puppeteer 甚至只是在瀏覽器 Javascript 中是否有一些通用方法可以將文本輸入到我缺少的 Flash TextArea 中? 謝謝。
嘗試使用更底層的 function ,例如keyboard.sendCharacter
,它不能處理keyboard.press
的所有奇怪事件處理。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.