autoease.core.api module¶
@author: meili
@contact: meili02@corp.netease.com
@file: api.py
@date: 2023/2/20 19:50
@desc:
- autoease.core.api.init_autoease(exp_mode='local', platform='Win64', game_project_name=None, record_id=None, is_record=False, is_upload_video=True, case_name='default_case', report_url='https://test-autoease.nie.netease.com/prod-server/reportRecord', logs_saved='autoease_logs/', case_info_log=None, case_error_log=None, **kwargs)[source]¶
Initialize the AutoEase instance as a global parameter
- Parameters:
exp_mode (Optional[str]) –
The mode of use scenario, defaults to “local”
- local: run locally, no report will be generated and upload to the web
- deploy: run in deployment mode. Parameters game_path, record_id must be given, and is_record must be set to True. Otherwise exp_mode will be set to “local”
game_path (Optional[str]) – the path to the game excutable
game_project_name (Optional[string]) – The name of the game project. This will be used to locate log files and keep the game process on top
record_id (Optional[int]) – the record_id of current test run, which will be used to assgin recorded videos to test report
report_url (Optional[str]) – the url to the AutoEase report backend, defaults to
https://test-autoease.nie.netease.com/prod-server/reportRecord
- Returns:
None
Examples
>>> init_autoease(exp_mode=RunMode.LOCAL, >>> game_path="D:/Projects/Dayly/LyraGame.exe", >>> game_project_name="LyraStarterGame")
- autoease.core.api.put_stage(name=None, **kwargs)[source]¶
A context manager which sets a new stage and put it to the test run,
- c
- Args:
- name(string):
The name of the test stage
- Return:
(Class object): A stage class instance with the given name
- Example:
>>> with put_stage(name="new test stage"): >>> key_press(key="W", duration=1) >>> mouse_click()
- autoease.core.api.wait(duration, **kwargs)[source]¶
pause for a period of time, a test step will be automatically added for this operation
- Parameters:
duration (float) – The time to be paused in seconds
- Returns:
None
Example
>>> wait(duration=5)
- autoease.core.api.get_resource(resource_name: str, **kwargs)[source]¶
Get the path of the given resource name. An error will be raised if the resource does not exist
- Parameters:
resource_name (string) – The name of the resource file
- Returns:
relative path of the resource
- Return type:
string
- Raises:
ResourceNotFoundError – If the resource does not exist
Example
>>> get_resource("check_keybinding_screen/keybinding_screen.png") >>> "testcase_resources/check_keybinding_screen/keybinding_screen.png"
- autoease.core.api.key_press(key, duration=0.05, **kwargs)[source]¶
simulate the key down input for a duration of time then key up, a test step will be automatically added for this operation
- Parameters:
key (string) – The keyboard key that user would like to press. Please see autoease/driver_control/keyboard.py for a detailed key mapping
duration (optional[non-negative float]) – the duration of the time the given key will be hold down, default to None, the key will be down and up instantly
- Returns:
None
Example
>>> key_press("R", duration=1)
- autoease.core.api.key_down(key, **kwargs)[source]¶
simulate the key down input, a test step will be automatically added for this operation
- Parameters:
key (string) – The keyboard key that user would like to hold down Please see autoease/driver_control/keyboard.py for a detailed key mapping
**kwargs – optional keyword arguments.
- Returns:
None
Example
>>> key_down("R")
- autoease.core.api.key_up(key, **kwargs)[source]¶
simulate the key up input, a test step will be automatically added for this operation
- Parameters:
key (string) – The keyboard key that user would like to release Please see autoease/driver_control/keyboard.py for a detailed key mapping
**kwargs – optional keyword arguments.
- Returns:
None
Example
>>> key_up("R")
- autoease.core.api.input_console_command(command: str, platform='unreal', **kwargs)[source]¶
Call out the default editor console and enter a command, a test step will be automatically added for this operation
- Parameters:
command (string) – The string of command user would like to enter to the console
platform (optional[string]) – name of the game engine, supports “unreal”. Defaults to “unreal“
- Returns:
None
Example
>>> input_console_command(command="bugitgo -641.45 1935.55 89.7 -1 -21.5", platform="unreal")
- autoease.core.api.key_write(words, duration=0.05, **kwargs)[source]¶
simulate keyboard input for a string, a test step will be automatically added for this operation
- Parameters:
words (string) – the string that user would like to enter
duration (optional[non-negative float]) – duration of pause between each character entry in seconds. Defaults to None, the entire command will be entered instantly
- Returns:
None
Example
>>> key_write(words="type_this", duration=1)
- autoease.core.api.gamepad_button_up(button, **kwargs)[source]¶
simulate the gamepad button up input, a test step will be automatically added for this operation
- Parameters:
button (string) – The gamepad button that user would like to release Please see autoease/driver_control/xbox_gamepad.py for a detailed button mapping Like use GAMEPAD_BUTTONS.BtnA, GAMEPAD_BUTTONS.BtnB….
**kwargs – optional keyword arguments.
- Returns:
None
Example
>>> gamepad_button_up(GAMEPAD_BUTTONS.BtnA)
- autoease.core.api.gamepad_button_down(button, **kwargs)[source]¶
simulate the gamepad button down input, a test step will be automatically added for this operation
- Parameters:
button (string) – The gamepad button that user would like to hold down Please see autoease/driver_control/xbox_gamepad.py for a detailed button mapping Like use GAMEPAD_BUTTONS.BtnA, GAMEPAD_BUTTONS.BtnB….
**kwargs – optional keyword arguments.
- Returns:
None
Example
>>> gamepad_button_down(GAMEPAD_BUTTONS.BtnA)
- autoease.core.api.gamepad_button_press(button, duration=0.05, **kwargs)[source]¶
simulate the gamepad button down input for a duration of time then button up, a test step will be automatically added for this operation
- Parameters:
button (string) – The gamepad button that user would like to press. Please see autoease/driver_control/xbox_gamepad.py for a detailed button mapping Like use GAMEPAD_BUTTONS.BtnA, GAMEPAD_BUTTONS.BtnB….
duration (optional[non-negative float]) – the duration of the time the given key will be hold down, default to None, the key will be down and up instantly
- Returns:
None
Example
>>> gamepad_button_press(GAMEPAD_BUTTONS.BtnA) >>> gamepad_button_press(GAMEPAD_BUTTONS.BtnA, duration=0.5)
- autoease.core.api.gamepad_left_joystick_set(x_value: float, y_value: float, duration=None, **kwargs)[source]¶
simulate set the gamepad left joystick x and y axis value, a test step will be automatically added for this operation
- Parameters:
x_value (float) – The value of x axis. Between -1.0 and 1.0.
y_value (float) – The value of y axis. Between -1.0 and 1.0.
duration (optional[non-negative float]) – the duration of the time behind setting the x and y axis, default to None,
- Returns:
None
Example
>>> gamepad_left_joystick_set(0, 1.0, duration=3) >>> gamepad_left_joystick_set(0, 0)
- autoease.core.api.gamepad_left_joystick_set_and_reset(x_value: float, y_value: float, duration=0.05, **kwargs)[source]¶
simulate set the gamepad left joystick x and y axis value for a while and reset, a test step will be automatically added for this operation
- Parameters:
x_value (float) – The value of x axis. Between -1.0 and 1.0.
y_value (float) – The value of y axis. Between -1.0 and 1.0.
duration (optional[non-negative float]) – the duration of the time between set value and reset, default to 0.05,
- Returns:
None
Example
>>> gamepad_left_joystick_set_and_reset(0, 1.0, duration=2)
- autoease.core.api.gamepad_right_joystick_set(x_value: float, y_value: float, duration=None, **kwargs)[source]¶
simulate set the gamepad right joystick x and y axis value, a test step will be automatically added for this operation
- Parameters:
x_value (float) – The value of x axis. Between -1.0 and 1.0.
y_value (float) – The value of y axis. Between -1.0 and 1.0.
duration (optional[non-negative float]) – the duration of the time behind setting the x and y axis, default to None,
- Returns:
None
Example
>>> gamepad_right_joystick_set(0, 1.0, duration=3) >>> gamepad_right_joystick_set(0, 0)
- autoease.core.api.gamepad_right_joystick_set_and_reset(x_value: float, y_value: float, duration=0.05, **kwargs)[source]¶
simulate set the gamepad right joystick x and y axis value for a while and reset, a test step will be automatically added for this operation
- Parameters:
x_value (float) – The value of x axis. Between -1.0 and 1.0.
y_value (float) – The value of y axis. Between -1.0 and 1.0.
duration (optional[non-negative float]) – the duration of the time between set value and reset, default to 0.05,
- Returns:
None
Example
>>> gamepad_right_joystick_set_and_reset(0, 1.0, duration=2)
- autoease.core.api.gamepad_left_trigger_set(value: float, duration=None, **kwargs)[source]¶
simulate set the gamepad left trigger value, a test step will be automatically added for this operation
- Parameters:
value (float) – The value of trigger. Between 0 and 1.0.
duration (optional[non-negative float]) – the duration of the time behind setting the trigger value, default to None,
- Returns:
None
Example
>>> gamepad_left_trigger_set(1.0, duration=3) >>> gamepad_left_trigger_set(0)
- autoease.core.api.gamepad_left_trigger_set_and_reset(value: float, duration=0.05, **kwargs)[source]¶
simulate set the gamepad left trigger value for a while and reset, a test step will be automatically added for this operation
- Parameters:
value (float) – The value of trigger. Between 0 and 1.0.
duration (optional[non-negative float]) – the duration of the time between set value and reset, default to None,
- Returns:
None
Example
>>> gamepad_left_trigger_set_and_reset(1.0, duration=3) >>> gamepad_left_trigger_set_and_reset(0)
- autoease.core.api.gamepad_right_trigger_set(value: float, duration=None, **kwargs)[source]¶
simulate set the gamepad right trigger value, a test step will be automatically added for this operation
- Parameters:
value (float) – The value of trigger. Between 0 and 1.0.
duration (optional[non-negative float]) – the duration of the time behind setting the trigger value, default to None,
- Returns:
None
Example
>>> gamepad_right_trigger_set(1.0, duration=3) >>> gamepad_right_trigger_set(0)
- autoease.core.api.gamepad_right_trigger_set_and_reset(value: float, duration=0.05, **kwargs)[source]¶
simulate set the gamepad right trigger value for a while and reset, a test step will be automatically added for this operation
- Parameters:
value (float) – The value of trigger. Between 0 and 1.0.
duration (optional[non-negative float]) – the duration of the time between set value and reset, default to None,
- Returns:
None
Example
>>> gamepad_right_trigger_set_and_reset(1.0, duration=3) >>> gamepad_right_trigger_set_and_reset(0)
- autoease.core.api.mouse_move_and_click(pos, duration=1, repeat=1, **kwargs)[source]¶
Move mouse to a position then simulate a click, a test step will be automatically added for this operation
- Parameters:
pos (tuple[float,float]) – the position on screen to move mouse to
duration (optional[non-negative float]) – the time takes to move mouse from the current position to the given position in seconds. Defaults to 1
repeat (optional[positive int]) – number of time the given mouse button will be pressed and released
- Returns:
None
Examples
>>> mouse_move_and_click(pos=(460,889), button="LEFT", duration=1, repeat=2)
- autoease.core.api.mouse_click(button='LEFT', duration=0.05, repeat=1, **kwargs)[source]¶
simulate a mouse click, a test step will be automatically added for this operation
- Parameters:
button (optional[string]) – the mouse button the user would like to click, default to “LEFT” Please see autoease/driver_control/mouse.py for a detailed key mapping
duration (optional[non-negative float]) – The duration of time the mouse button will be hold down until released in seconds. Defaults to None, the button will be clicked then released instantly
repeat (optional[int]) – number of time the given mouse button will be pressed and released
- Returns:
None
Examples
>>> mouse_click(button="MIDDLE", duration=1, repeat=1)
- autoease.core.api.mouse_double_click(button='LEFT', duration=0.05, repeat=1, **kwargs)[source]¶
simulate double click on a mouse button a test step will be automatically added for this operation
- Parameters:
button (optional[string]) – the mouse button to click, default to “LEFT” Please see autoease/driver_control/mouse.py for a detailed key mapping
duration (optional[non-negative float]) – The duration of time paused between each double-click. Defaults to None, no pause between double clicks
repeat (optional[int]) – number of time the given mouse button will be double-clicked, defaults to 1
- Returns:
None
Examples
>>> mouse_double_click(button="RIGHT", duration=1, repeat=1)
- autoease.core.api.mouse_drag(pos1: tuple, pos2: tuple, button='LEFT', duration=1, **kwargs)[source]¶
Move mouse to a position then simulate a button press down, then move to a position and release the mouse button. A test step will be automatically added for this operation
- Parameters:
pos1 (tuple[float,float]) – the position on screen to move mouse to before press down the given mouse button
pos2 (tuple[float,float]) – the position on screen to move mouse to after press down the given mouse button
button (optional[string]) – the mouse button to click, default to “LEFT” Please see autoease/driver_control/mouse.py for a detailed key mapping
duration (optional[non-negative float]) – the time takes to move mouse from the pos1 to pos2 in seconds. Defaults to None
- Returns:
None
Examples
>>> mouse_drag(pos1=(0.0,0), pos2=(100,100.5), button="LEFT", duration=1)
- autoease.core.api.mouse_move(pos: tuple, **kwargs)[source]¶
simulate a mouse move, a test step will be automatically added for this operation
- Parameters:
pos1 (tuple[float,float]) – the position on screen to move mouse
- Returns:
None
Examples
>>> mouse_move((900, 900))
- autoease.core.api.mouse_wheel(steps: int, direction='FORWARD', duration=0.05, **kwargs)[source]¶
simulate mouse use wheel a test step will be automatically added for this operation
- Parameters:
steps (int) – the steps to use wheel movement.
direction (optional[non-negative str]) – ‘FORWARD’ or ‘BACK’. The direction of wheel movement, defaults to ‘FORWARD’.
duration (optional[non-negative float]) – the time among each wheel movement. Defaults to 0.05
- Returns:
None
Examples
>>> mouse_wheel(1, button="FORWARD") >>> mouse_wheel(2, button="BACK", duration=1)
- autoease.core.api.img_exist(img, **kwargs)[source]¶
Check whether the given target exists on device screen. A test step will be automatically added for this operation —-
- Parameters:
img (class object[Template]) – the image of the target to be checked
**kwargs – optional keyword arguments.
- Returns:
False if target is not found, otherwise returns the center coordinates (X,Y) of target’s location
- Return type:
Boolean or Tuple(float,float)
Examples
>>> img_exist(Image("testcase_resources/ability_test/ability_slot.png")) >>> (100, 200) or >>> img_exist(Image(get_resource("ability_test/ability_slot.png"))) >>> False
- autoease.core.api.assert_img_exists(img, **kwargs)[source]¶
Check whether given target exists on device screen. A test step will be automatically added for this operation
- Parameters:
img (class object[Template]) – the image of the target to be checked
**kwargs – optional keyword arguments.
- Returns:
the center coordinates (X,Y) of the target’s location if the target is found, raise an error otherwise
- Return type:
Tuple(float,float)
- Raises:
AssertionError – If the target is not found
Examples
>>> assert_img_exists(Image("testcase_resources/ability_test/ability_slot.png")) >>> (100, 200) or >>> assert_img_exists(Image(get_resource("ability_test/ability_slot.png"))) >>> Traceback (most recent call last): >>> ... >>> AssertionError: Template(...) does not exist in screen, message:
- autoease.core.api.assert_img_not_exists(img, **kwargs)[source]¶
Check whether given target not exist on device screen. A test step will be automatically added for this operation
- Parameters:
img (class object[Template]) – the image of the target to be checked
**kwargs – optional keyword arguments.
- Returns:
None
- Raises:
AssertionError – If the target is found
Examples
>>> assert_img_not_exists(Image("testcase_resources/ability_test/ability_slot.png")) or >>> assert_img_not_exists(Image(get_resource("ability_test/ability_slot.png")))
- autoease.core.api.img_click(img, **kwargs)[source]¶
Move mouse to the position of the target and click the left mouse button. A test step will be automatically added for this operation
- Parameters:
img (class object[Template]) – the image of the target to be checked
**kwargs – optional keyword arguments, supports duration(float), times(int)
- Returns:
the center coordinates (X,Y) of the target’s location if the target is found, raise an error otherwise
- Return type:
Tuple(float,float)
- Raises:
TargetNotFoundError – If the target is not found on screen
Examples
>>> img_click(Image(get_resource("module/login_game/login_screen.png"))) >>> (100, 200)
- autoease.core.api.img_double_click(img, **kwargs)[source]¶
Move mouse to the position of the target and double-click the left mouse button. A test step will be automatically added for this operation
- Parameters:
img (class object[Template]) – the image of the target to be checked
**kwargs – optional keyword arguments, supports duration(float), times(int)
- Returns:
the center coordinates (X,Y) of the target’s location if the target is found, raise an error otherwise
- Return type:
Tuple(float,float)
- Raises:
TargetNotFoundError – If the target is not found on screen
Examples
>>> img_double_click(Image(get_resource("module/login_game/login_screen.png"))) >>> (100, 200)
- autoease.core.api.ocr_exist_sentence(word_list, **kwargs)[source]¶
Check whether given word_list exists in a sentence on device screen. A test step will be automatically added for this operation
- Parameters:
word_list (list[string]) – list of strings to be checked
- Returns:
The four conner coordinates of the rectangle where the list of strings have been found on screen. return False if not all strings have been found
- Return type:
list[(float, float), (float, float), (float, float), (float, float)])
Examples
>>> ocr_exist_sentence(["Test", "word", "list"]) >>> [(100, 200), (300, 200), (300, 250), (100, 250)]
- autoease.core.api.ocr_assert_exist_sentence(word_list, **kwargs)[source]¶
Check whether given word_list exists in a sentence on device screen. A test step will be automatically added for this operation
- Parameters:
word_list (list[string]) – list of strings to be asserted
- Returns:
The four conner coordinates of the rectangle where the list of strings have been found on screen.
- Return type:
list[(float, float), (float, float), (float, float), (float, float)])
- Raises:
TargetNotFoundError – If not all strings in word_list are not found
Examples
>>> ocr_assert_exist_sentence(["Test", "word", "list"]) >>> [(100, 200), (300, 200), (300, 250), (100, 250)] >>> ocr_assert_exist_sentence(["Test", "word", "list"]) >>> Traceback (most recent call last): >>> ... >>> TargetNotFoundError: OCR can not find the sentence ... in screen:
- autoease.core.api.ocr_exist_sentence_on_screen_rectangle(x1: int, y1: int, x2: int, y2: int, word_list: list, **kwargs)[source]¶
Check whether given word_list exists in a sentence in a rectangle on the device screenshot. A test step will be automatically added for this operation
- Parameters:
x1 – the x-axis of the bottom-left corner of the rectangle on device screen
y1 – the y-axis of the bottom-left corner of the rectangle on device screen
x2 – the x-axis of the top-right corner of the rectangle on device screen
y2 – the y-axis of the top-right corner of the rectangle on device screen
word_list (list[string]) – A list of strings to be checked
**kwargs – optional keyword arguments, supports quality(int)
- Returns:
The four conner coordinates of the rectangle where the list of strings have been found on screen. Return string if recognize text don’t match
- Return type:
list[(float, float), (float, float), (float, float), (float, float)]) or string
Examples
>>> ocr_exist_sentence_on_screen_rectangle(900, 771, 1020, 794, ["KILLS", ":", "1"]) >>> [(900, 771), (1020, 771), (1020, 794), (900, 794)] >>> ocr_exist_sentence_on_screen_rectangle(900, 771, 1020, 794, ["KILLS", ":", "1"]) >>> "KILLS:2"
- autoease.core.api.ocr_click(sentence: str, **kwargs)[source]¶
Find the given string in screen, then move mouse to the center of the position and click the left mouse button. A test step will be automatically added for this operation
- Parameters:
sentence (string) – the sentence to be asserted
- Returns:
The four conner coordinates of the rectangle where the list of strings have been found on screen. Raise an error otherwise
- Return type:
list[(float, float), (float, float), (float, float), (float, float)])
- Raises:
TargetNotFoundError – If the given string is not found on screen
Examples
>>> ocr_click("Play") >>> ocr_click("Open") >>> Traceback (most recent call last): >>> ... >>> TargetNotFoundError: Sentence Open not found in screen:
- autoease.core.api.assert_is_not_false(a, msg='', **kwargs)[source]¶
Assert whether a variable is NOT False(boolean). A test step will be automatically added for this operation
- Parameters:
a – the variable to be asserted
msg (string) – The printout message if the given variable is False
- Returns:
None
- Raises:
AssertionError – if the given variable is False
Examples
>>> assert_is_not_false(flag, msg="The flag is False!")
- autoease.core.api.assert_is_false(a, msg='', **kwargs)[source]¶
Assert whether a variable is False(boolean). A test step will be automatically added for this operation
- Parameters:
a – the variable to be asserted
msg (string) – The printout message if the given variable is NOT False
- Returns:
None
- Raises:
AssertionError – if the given variable is anything other than False
Examples
>>> assert_is_false(flag, msg="The flag is not False!")
- autoease.core.api.assert_is_true(a, msg='', **kwargs)[source]¶
Assert whether a variable is True(boolean). A test step will be automatically added for this operation
- Parameters:
a – the variable to be asserted
msg (string) – The printout message if the given variable is NOT True
- Returns:
None
- Raises:
AssertionError – if the given variable is anything other than True
Examples
>>> assert_is_true(flag, msg="The flag is not True!")
- autoease.core.api.assert_is_not_true(a, msg='', **kwargs)[source]¶
Assert whether a variable is NOT True(boolean). A test step will be automatically added for this operation
- Parameters:
a – the variable to be asserted
msg (string) – The printout message if the given variable is True
- Returns:
None
- Raises:
AssertionError – if the given variable is True
Examples
>>> assert_is_not_true(flag, msg="The flag is True!")
- autoease.core.api.assert_equal(a, b, tolerance=0, msg: str = '', **kwargs)[source]¶
Assert two variables whether equal or not with tolerance. A test step will be automatically added for this operation
- Parameters:
a – the first variable
b – the second variable
tolerance – the tolerance of comparing a and b
msg (string) – if a and b not equal then will out put the msg
- Returns:
None
- Raises:
AssertionError – if variable a is not equal to variable b
Examples
>>> assert_equal(1, 1, tolerance=1, msg="assert 1==1")
- autoease.core.api.assert_greater(a, b, msg='', **kwargs)[source]¶
Assert whether a variabel is greater than another variable. A test step will be automatically added for this operation
- Parameters:
a – the first variable
b – the second variable
msg (string) – the printout message if a is not greater than b
- Returns:
None
- Raises:
AssertionError – if variable a is not greater than variable b
Examples
>>> assert_greater(1, 1, msg="assert 1>1")
- autoease.core.api.assert_greater_equal(a, b, msg='', **kwargs)[source]¶
Assert whether a variabel is greater than or equal to another variable. A test step will be automatically added for this operation
- Parameters:
a – the first variable
b – the second variable
msg (string) – the printout message if a is not greater or equal than b
- Returns:
None
- Raises:
AssertionError – if variable a is not greater than or equal to variable b
Examples
>>> assert_greater_equal(1, 1, msg="assert 1>=1")
- autoease.core.api.assert_less(a, b, msg='', **kwargs)[source]¶
Assert whether a variabel is less than another variable. A test step will be automatically added for this operation
- Parameters:
a – the first variable
b – the second variable
msg (string) – the printout message if a is not less than b
- Returns:
None
- Raises:
AssertionError – if variable a is not less than variable b
Examples
>>> assert_less(1, 1, msg="assert 1<1")
- autoease.core.api.assert_less_equal(a, b, msg='', **kwargs)[source]¶
Assert whether a variabel is less than or equal to another variable. A test step will be automatically added for this operation
- Parameters:
a – the first variable
b – the second variable
msg (string) – the printout message if a is not less or equal than b
- Returns:
None
- Raises:
AssertionError – if variable a is not less than or equal to variable b
Examples
>>> assert_less_equal(1, 1, msg="assert 1<=1")
- autoease.core.api.wait_for_keyword(keyword, log_file_path=None, timeout=20, is_rematch=False, opfunc=None, **kwargs)[source]¶
Monitor new input to the log file and search for keywords. A test step will be automatically added for this operation
- Parameters:
keyword (string) – The keywords to look for
timeout (float) – maximum time of monitoring in seconds
is_rematch (Boolean) – If True, look for keywords by regular expression. If False, look for the exact given keywords.
opfunc (function) – The function to be excuted when keywords appear in the log file
- Returns:
The entire line of the log where the keywords are found. False if no log input contains the given keywords before timeout.
- Return type:
String or Boolean
Examples
>>> wait_for_keyword("LogWorld: Bringing World /Game/Provisional/QA/Maps/Smoke_01/Smoke_01.Smoke_01", timeout=20, is_rematch=False, opfunc=mouse_click) >>> "[2023.04.03-03.49.18:825][816]LogWorld: Bringing World /Game/Provisional/QA/Maps/Smoke_01/Smoke_01.Smoke_01 up for play (max tick rate 0) at 2023.04.03-11.49.18" or >>> wait_for_keyword("LogWorld: Bringing World /Game/Provisional/QA/Maps/Smoke_01/Smoke_01.Smoke_01", timeout=20, is_rematch=False, opfunc=mouse_click) >>> False
- autoease.core.api.assert_log_exist(keyword, log_file_path=None, timeout=20, is_rematch=False, opfunc=None, **kwargs)[source]¶
Monitor new input to the log file and search for keywords. A test step will be automatically added for this operation
- Parameters:
keyword (string) – The keywords to look for
timeout (float) – maximum time of monitoring in seconds
is_rematch (Boolean) – If True, look for keywords by regular expression. If False, look for the exact given keywords
opfunc (function) – The function to be excuted when keywords appear in the log file
- Returns:
The entire line of the log where the keywords are found.
- Return type:
String
- Raises:
TargetNotFoundError – if no log input contains the given keywords before timeout
Examples
>>> assert_log_exist("LogWorld: Bringing World /Game/Provisional/QA/Maps/Smoke_01/Smoke_01.Smoke_01", timeout=20, is_rematch=False, opfunc=mouse_click) >>> "[2023.04.03-03.49.18:825][816]LogWorld: Bringing World /Game/Provisional/QA/Maps/Smoke_01/Smoke_01.Smoke_01 up for play (max tick rate 0) at 2023.04.03-11.49.18" or >>> assert_log_exist("LogWorld: Bringing World /Game/Provisional/QA/Maps/Smoke_01/Smoke_01.Smoke_01", timeout=20, is_rematch=False, opfunc=mouse_click) >>> Traceback (most recent call last): >>> ... >>> TargetNotFoundError: Log keyword ... not found in ...:
- autoease.core.api.fail(message: str = 'This case has failed!', **kwargs)[source]¶
Raise an error with the given message. A test step will be automatically added for this operation
- Parameters:
message (string) – The error message to be raised with, defaults to “This case has failed!”
- Returns:
None
- Raises:
RuntimeError – when the function is called
Examples
>>> fail("The armor is not reduced!") >>> Traceback (most recent call last): >>> ... >>> RuntimeError: The armor is not reduced!:
- autoease.core.api.success(message: str = 'This case has succeed!', **kwargs)[source]¶
This function can be used to add a “success” test step
- Returns:
None
Examples
>>> success("The armor is reduced!")
- class autoease.core.api.AUTOEASE_PARAMS[source]¶
Bases:
object
- MODE = 'mode'¶
- RECORD_ID = 'record_id'¶
- GAME_PATH = 'game_path'¶
- PLATFORM = 'platform'¶