-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopen_chrome.js
46 lines (43 loc) · 1.16 KB
/
open_chrome.js
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
import { Builder } from 'selenium-webdriver'
import chrome from 'selenium-webdriver/chrome'
import spawn from 'spawncommand'
import main from './src/main'
const driver = new Builder()
.forBrowser('chrome')
.setChromeOptions(new chrome.Options()
.addArguments('disable-infobars'))
.build()
// kCGWindowIsOnscreen
// kCGWindowLayer
// kCGWindowMemoryUsage
// kCGWindowName
// kCGWindowNumber
// kCGWindowOwnerName
// kCGWindowOwnerPID
// kCGWindowSharingState
// kCGWindowStoreType
async function active(app) {
await spawn('osascript', [
'-e',
`tell application "${app}" to activate`,
])
}
(async () => {
try {
await driver.get('https://artdeco.bz/appshot')
await active('Chrome')
// await driver.executeScript('alert("focus")')
// await driver.switchTo().alert().accept()
// const body = await driver.findElement({ tagName: 'body'})
// await body.click()
await new Promise(r => setTimeout(r, 100))
await main('screenshots', 'Chrome', 'Art Deco')
} catch ({ stack, message }) {
if (/appshot/.test(process.env.NODE_DEBUG)) {
console.log(stack)
} else {
console.log(message)
}
}
await driver.quit()
})()