@add_attributes(TCID="TC1000", name="TC_TO_RESTORE1", order=1)
def TC_TO_RESTORE1():
app = RestartPME()
if app is None:
LogMessage(f"Failed to launch PME", False)
return False
time.sleep(3)
projectName = 'G326SE6'
targetName = 'G326SE6'
window_title = 'PAC Machine Edition'
app = Application(backend="uia").connect(title=window_title)
main_window = app.window(title=window_title)
main_window.wait('ready', timeout=10)
# #Restore Project
current_directory = os.getcwd()
project_directory = current_directory + "\\" + "Projects" + "\\" + "G326SE6.zip"
if os.path.isfile(project_directory) is False:
LogMessage(f"Project {project_directory} couldn't be found",False)
return False
result = destroy_project(app, window_title, projectName)
if result == False:
LogMessage(f"Destroy project failed",False)
return False
result = restore_project(app,main_window,window_title,project_directory, projectName)
if result == False:
LogMessage(f"Restore project failed",False)
return False
# Validate the Target
result = validate_target(app, main_window,window_title,projectName,targetName, False)[0]
if result == False:
print("Target Validation Failed")
Below is the definition for validate_target
def validate_target(app, main_window, window_title, projectName, targetName, validateAll):
window_title = projectName + ' - PAC Machine Edition'
if validateAll == True:
contextMenuItem = 'Validate All'
selectednode = select_navigation_node(app, window_title, projectName, projectName, False)
else:
contextMenuItem = 'Validate\tF7'
selectednode = select_navigation_node(app, window_title, projectName, targetName, False)
if selectednode is not None:
draw_context_menu(selectednode)
result = select_context_menu_item(app, window_title, contextMenuItem)
return result
return False
And the error is - "
FAIL: TC_TO_RESTORE1 failed due to exception There are 2 elements that match the criteria {‘title_re’: ‘G326SE6’, ‘control_type’: ‘TreeItem’, ‘top_level_only’: False, ‘enabled_only’: False, ‘visible_only’: False, ‘parent’: <uia_element_info.UIAElementInfo - ‘G326SE6 - PAC Machine Edition’, FrameworXClass, 25888182>, ‘backend’: ‘uia’}"
The code seems to find 2 elements for “result = validate_target(app, main_window,window_title,projectName,targetName, False)[0]”