Created
March 18, 2023 04:55
-
-
Save hogelog/8169ac693fbb03f067bbb81519e22643 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch({ headless: false }); | |
const context = browser.defaultBrowserContext(); | |
await context.overridePermissions('https://stretch3.github.io', ['camera', 'microphone']); | |
const page = (await browser.pages())[0]; | |
await page.goto('https://stretch3.github.io/'); | |
const uploadfile = '/home/pi/robot/scratch3-autostart/main.sb3'; | |
const fileMenu = (await page.$x("//*[contains(text(), 'ファイル')]"))[0]; | |
await fileMenu.click() | |
const loadMenu = (await page.$x("//*[contains(text(), 'コンピューターから読み込む')]"))[0]; | |
const [fileChooser] = await Promise.all([ | |
page.waitForFileChooser(), | |
loadMenu.click(), | |
]); | |
await fileChooser.accept([uploadfile]); | |
await page.bringToFront(); | |
await page.waitForTimeout(2000); | |
const executeButton = await page.$('[title="実行"]'); | |
await executeButton.click(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment