-
Notifications
You must be signed in to change notification settings - Fork 21
/
demo2.sh
50 lines (41 loc) · 1.07 KB
/
demo2.sh
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
47
48
49
50
#!/usr/bin/env bash
source ./lib/selenium.sh --headless
main() {
screen_clear
navigate_to 'https://www.google.com/?gl=us&hl=en&gws_rd=cr&pws=0'
local searchBox=$(find_element 'name' 'q')
set_background_image
# Enter one character at a time to give the feeling of typing
local words=('d' 'o' 'g' '\n')
for word in ${words[@]}; do
send_keys $searchBox $word
set_background_image $word
done
for i in `seq 0 100 1000`; do
exec_script "window.scroll(0,$i)"
set_background_image $i
done
screen_clear
delete_session
}
iterm_set_background_image() {
osascript << EOF
tell application "iTerm"
activate
set _current_session to current session of current window
tell _current_session
set background image to "$1"
end tell
end tell
EOF
}
set_background_image() {
local screenshotPath="$(pwd)/demo-image-${1}.jpg"
screenshot $screenshotPath
iterm_set_background_image $screenshotPath
}
screen_clear() {
clear
iterm_set_background_image ''
}
main