-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
32 lines (23 loc) · 804 Bytes
/
test.py
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
import os
import imghash
import selenium.webdriver
def test(driver):
# TODO start webserver
driver.get("http://127.0.0.1:8000/test.html")
driver.set_script_timeout(60)
element = driver.find_element_by_id("file")
test_folder = os.path.join(os.path.dirname(__file__), "test")
for img in os.listdir(test_folder):
img = os.path.abspath(os.path.join(test_folder, img))
element.send_keys(img)
js_hash = driver.execute_async_script(
"get_file_hash(arguments[arguments.length - 1])"
)
py_hash = imghash.get_hash(img)
assert js_hash == py_hash.hexdigest(), (js_hash, py_hash.hexdigest(), img)
def main():
driver = selenium.webdriver.Chrome()
test(driver)
driver.close()
if __name__ == "__main__":
main()