/
test_temperature.py
65 lines (51 loc) · 1.65 KB
/
test_temperature.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
57
58
59
60
61
62
63
64
65
"""
Perform UI test on the Ocean Navigator
==========================
:Author: Samuel Babalola
:Created: 2020-02-11
This module finds the temperature colour
of the ocean navigator navigator.
"""
from datetime import datetime
import pyautogui as gui
import time
import yaml
from dimension_config import (open_config, write_to_config)
from utils import (navigator_webpage, get_time,
retry_location_test, move_et_click)
#Open configuration file
config = open_config()
dimension = config['location']
paths = config['paths']
address = config['web_addresses']
duration = config['duration']
# Set default sleep time
sleep = duration['sleep']
plot_render_sleep = duration['plot_render']
box_timeout = duration['box_timeout']
def find_temperature_bar():
"""
Function to locate the temperature bar on
the ocean navigator public page.
"""
result = None
time.sleep(2)
screenWidth, screenHeight = gui.size()
# Go to the navigator web page
#navigator_webpage()
# Locate temperature color bar on public page
image_loc = gui.locateCenterOnScreen(
paths['test_temperature'], confidence=0.7, grayscale=True)
if image_loc is None:
gui.alert(text='Temperature bar not found!', title='Temperature bar', button='OK')
result = 'Test Failed'
else:
gui.click(button='right', x=image_loc.x, y=image_loc.y)
gui.alert(text='Temperature bar check complete!', title='Temperature bar', button='Close', timeout=box_timeout)
result = 'Test Completed'
return result, get_time()
def main():
navigator_webpage()
find_temperature_bar()
if __name__ == '__main__':
main()