-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.sh
More file actions
29 lines (20 loc) · 611 Bytes
/
demo.sh
File metadata and controls
29 lines (20 loc) · 611 Bytes
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
#!/bin/sh
set -eu
. ./lib/webdriver.sh
chrome_options() {
echo '{ "args": [] }'
# echo '{ "args": ["--headless"] }'
}
WebDriver driver="$(ChromeDriver chrome_options "http://localhost:9515")"
driver get "https://www.google.com"
WebElement element="$(driver find_element "css selector:[name=q]")"
element send_keys "WebDriver" :enter
# **Shorthand**
# driver find_element 'css selector:[name=q]' send_keys "WebDriver" :enter
for element_id in $(driver find_elements "css selector:a"); do
WebElement element="$element_id"
element attribute "text"
done
sleep 3
driver quit
unset -f element driver