Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
time.sleep(sleep)
# Draw a counding box for line test
start_point = dimension['map_point']
direction = 80
move_right = (start_point[0] + direction, start_point[1])
move_down = (move_right[0], move_right[1] - direction)
move_left = (move_down[0] - direction, move_down[1])
move_up = (move_left[0], move_left[1] + direction)
move_et_click(dimension['map_point'])
move_et_click(move_right)
move_et_click(move_down)
move_et_click(move_left)
move_et_click(move_up)
gui.click(move_up)
time.sleep(plot_render_sleep)
gui.alert('Conducting test...', 'Wait', timeout=4000)
# Find expected plot
image_loc = gui.locateCenterOnScreen(
paths['line_index'], confidence=0.3, grayscale=True)
if image_loc is None:
gui.alert(text='Line index not found!', title='UI test', button='OK', timeout=box_timeout)
# Retry the test in case of slow network connection
retry_location_test(paths['line_index'], 'Line Index')
result = 'Test Failed'
else:
gui.alert(text='Line UI test complete!', title='UI test', button='Close', timeout=box_timeout)
result = 'Test Completed'
line_index_results['Profile'] = result
#Hovmoller Diagram test
point_tests(paths['line_index'], line_index_results)
move_left = (move_down[0] - direction, move_down[1])
move_up = (move_left[0], move_left[1] + direction)
move_et_click(dimension['map_point'])
move_et_click(move_right)
move_et_click(move_down)
move_et_click(move_left)
move_et_click(move_up)
gui.click(move_up)
time.sleep(plot_render_sleep)
gui.alert('Conducting test...', 'Wait', timeout=4000)
# Find expected plot
image_loc = gui.locateCenterOnScreen(
paths['line_index'], confidence=0.3, grayscale=True)
if image_loc is None:
gui.alert(text='Line index not found!', title='UI test', button='OK', timeout=box_timeout)
# Retry the test in case of slow network connection
retry_location_test(paths['line_index'], 'Line Index')
result = 'Test Failed'
else:
gui.alert(text='Line UI test complete!', title='UI test', button='Close', timeout=box_timeout)
result = 'Test Completed'
line_index_results['Profile'] = result
#Hovmoller Diagram test
point_tests(paths['line_index'], line_index_results)
# Close index sub-tab
time.sleep(.30)
gui.click(dimension['close_index'])
time.sleep(.30)
return line_index_results
def hello_world():
pyautogui.alert("Hello World", "Hello World Head")
Assumption, user ran the temperature bar test
so firefox and the navigator page are open.
"""
result = None
gui.alert('Moving on...', 'Test', timeout=box_timeout)
time.sleep(.30)
move_et_click(location)
# Additional 5 seconds
time.sleep(10)
# Find expected plot
image_loc = gui.locateCenterOnScreen(
test_index, confidence=0.3, grayscale=True)
if image_loc is None:
gui.alert(text='Index failed time test!', title='{}'.format(
ui_test), button='OK', timeout=box_timeout)
result = 'Index failed time(10 seconds) test'
else:
time.sleep(0)
gui.alert(text='UI test complete!', title='{}'.format(
ui_test), button='Close', timeout=box_timeout)
result = 'Test Completed'
# Log resultd
test_date = datetime.now()
test_date = test_date.strftime("%A, %d. %B %Y %H:%M:%S")
log_result[ui_test] = result
log_time[ui_test] = test_date
return result
Function retries image location. There could
be cases where there is a slow internet connection
Assumption, user ran the temperature bar test
so firefox and the navigator page are open.
"""
gui.alert('Retry test...', 'Wait', timeout=box_timeout)
# Additional 5 seconds
time.sleep(5)
# Find expected plot
image_loc = gui.locateCenterOnScreen(
test_index, confidence=0.3, grayscale=True)
if image_loc is None:
gui.alert(text='Index not found!', title='{}'.format(ui_test), button='OK', timeout=box_timeout)
else:
time.sleep(0)
gui.alert(text='UI test complete!', title='{}'.format(ui_test), button='Close', timeout=box_timeout)
if ret:
# 制作缩略图
image = Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
image.thumbnail((500, 300))
if not os.path.exists('./picture'):
os.mkdir('./picture')
image.save("./picture/face.jpg", format='jpeg')
del frame, ret, image
break
else:
self.logger.error('拍照失败,重试...')
if self.GET_FACE_TIME < self.RETRY_TIME:
self.GET_FACE_TIME += 1
else:
self.logger.error('拍照失败,重试次数已用尽,程序退出')
pag.alert('拍照失败,重试次数已用尽,程序退出', title=self.ALERT_TITLE, timeout=self.ALERT_TIMEOUT)
exit()
cap.release()
def pause(self):
'''Shows a dialog that must be dismissed with manually clicking.
This is mainly for when you are developing the test case and want to
stop the test execution.
It should probably not be used otherwise.
'''
ag.alert(text='Test execution paused.', title='Pause',
button='Continue')