File: test-chromium

package info (click to toggle)
python-selenium 4.8.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,348 kB
  • sloc: python: 14,352; javascript: 2,347; makefile: 118; sh: 48
file content (45 lines) | stat: -rwxr-xr-x 1,268 bytes parent folder | download
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
#!/bin/sh

set -exu

python3 -m http.server 8000 --bind 127.0.0.1 --directory="$(pwd)" &
pid=$!
trap "kill $pid" EXIT

cat << END | python3
import sys
sys.path.remove('')
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--remote-debugging-port=9229")
chrome_options.add_argument("--window-size=1024x768")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--no-sandbox")

driver = webdriver.Chrome(options = chrome_options)

print("Getting data from http://127.0.0.1:8000")

if driver.get("http://127.0.0.1:8000") == None:
    print("Success.")
else:
    print("Failed!")

print("Looking for a link named 'debian/'")
link = driver.find_element(By.LINK_TEXT, "debian/")

if link.click() == None:
    print("Success.")
else:
    print("Failed!")

print("\nTest seems to be successful!\nTest was using the following HTML data to test the Chrome webdriver.\n")
print("------------------------------- %< -------------------------------")
print(driver.page_source)
print("------------------------------- >% -------------------------------")
END