-
Notifications
You must be signed in to change notification settings - Fork 65
/
test_win_get.py
56 lines (46 loc) · 1.33 KB
/
test_win_get.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import os
import time
project_root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../..'))
sys.path.insert(0, project_root)
from ahk import AHK
from ahk.window import WindowNotFoundError
import pytest
import subprocess
ahk = AHK()
def test_get_calculator():
p = None
try:
p = subprocess.Popen('notepad')
time.sleep(1) # give notepad time to start up
win = ahk.win_get(title='Untitled - Notepad')
assert win
assert win.position
finally:
if p is not None:
p.terminate()
def test_win_close():
p = None
try:
p = subprocess.Popen('notepad')
time.sleep(1) # give notepad time to start up
win = ahk.win_get(title='Untitled - Notepad')
assert win
assert win.position
win.close()
assert ahk.win_get(title='Untitled - Notepad') is None
finally:
if p is not None:
p.terminate()
def test_find_window_func():
p = None
try:
p = subprocess.Popen('notepad')
time.sleep(1) # give notepad time to start up
def func(win):
return b'Untitled' in win.title
win = ahk.find_window(title=b'Untitled - Notepad')
assert win == ahk.find_window(func=func)
finally:
if p is not None:
p.terminate()