File: test_start.py

package info (click to toggle)
python-pywebview 2.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,376 kB
  • sloc: python: 3,816; cs: 116; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 821 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
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():
    run_test(webview, main_func, assert_func)


def main_func():
    api = Api()
    webview.create_window('Relative URL test', 'assets/test.html', js_api=api)


def assert_func():
    sleep(1)
    html_result = webview.evaluate_js('document.getElementById("heading").innerText')
    assert html_result == 'Hello there!'

    css_result = webview.evaluate_js('window.getComputedStyle(document.body, null).getPropertyValue("background-color")')
    assert css_result == 'rgb(255, 0, 0)'

    js_result = webview.evaluate_js('window.testResult')
    assert js_result == 80085

    assert_js(webview, 'test', 'JS Api is working too')