mirror of
https://github.com/allankoechke/pywebview.git
synced 2026-11-30 10:58:50 +00:00
33 lines
843 B
Python
33 lines
843 B
Python
import os
|
|
from time import sleep
|
|
from .util import run_test, assert_js
|
|
import webview
|
|
|
|
class Api:
|
|
def test(self, params):
|
|
return 'JS Api is working too'
|
|
|
|
|
|
def test_start():
|
|
api = Api()
|
|
window = webview.create_window('Relative URL test', 'assets/test.html', js_api=api)
|
|
run_test(webview, window, assert_func, start_args={'http_server': True})
|
|
|
|
|
|
def assert_func(window):
|
|
sleep(1)
|
|
html_result = window.evaluate_js('document.getElementById("heading").innerText')
|
|
assert html_result == 'Hello there!'
|
|
|
|
css_result = window.evaluate_js('window.getComputedStyle(document.body, null).getPropertyValue("background-color")')
|
|
assert css_result == 'rgb(255, 0, 0)'
|
|
|
|
js_result = window.evaluate_js('window.testResult')
|
|
assert js_result == 80085
|
|
|
|
assert_js(window, 'test', 'JS Api is working too')
|
|
|
|
|
|
|
|
|