File: test.py

package info (click to toggle)
node-nouislider 15.8.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,936 kB
  • sloc: javascript: 5,234; php: 474; sh: 32; python: 28; makefile: 11
file content (37 lines) | stat: -rw-r--r-- 1,025 bytes parent folder | download | duplicates (2)
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
# run qunit tests using selenium

import os
import selenium.webdriver as webdriver
import selenium.webdriver.common.by as by
import selenium.webdriver.support.expected_conditions as EC
import selenium.webdriver.support.ui as ui
import sys

mode = sys.argv[1]
if mode == "build":
    test_path = os.getcwd()
elif mode == "autopkgtest":
    test_path = "/usr/share/doc/node-nouislider"
else:
    raise ValueError("unknown mode")

options = webdriver.chrome.options.Options()
options.add_argument("--headless")
options.add_argument("--no-sandbox")

try:
    driver = webdriver.Chrome(options=options)
except:
    print("warning: unable to set up web driver; skipping")
    exit(77 if mode == "autopkgtest" else 0)

driver.get(f"file://{test_path}/tests/slider.html")

ui.WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((by.By.CLASS_NAME, "failed")))

print(driver.find_element(by.By.ID, "qunit-testresult").text)
failed = int(driver.find_element(by.By.CLASS_NAME, "failed").text)

driver.quit()
exit(failed)