Skip to content

Commit d6d04a7

Browse files
Merge pull request #483 from AutomationSolutionz/zai
Allow turn off auto switch window
2 parents 28cf600 + 8e4c2f6 commit d6d04a7

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,8 @@ def _child_search_by_path(
826826
if found:
827827
if switch_window:
828828
CommonUtil.ExecLog(sModuleInfo, "Switching to window: %s" % NameE, 1)
829-
autoit.win_activate(NameE)
829+
if Shared_Resources.Get_Shared_Variables("zeuz_window_auto_switch").strip().lower() in CommonUtil.Affirmative_words:
830+
autoit.win_activate(NameE)
830831
all_elements.append(each_child)
831832
if 0 <= element_index == len(all_elements) - 1: break
832833

@@ -1627,15 +1628,17 @@ def _get_main_window(WindowName):
16271628
if MainWindowElement.Current.ProcessId in current_pid_list:
16281629
CommonUtil.ExecLog(sModuleInfo, "Switching to window: %s" % NameS, 1)
16291630
CommonUtil.ExecLog(sModuleInfo, f"pid matched: {MainWindowElement.Current.ProcessId}", 5)
1630-
autoit.win_activate(NameS)
1631+
if Shared_Resources.Get_Shared_Variables("zeuz_window_auto_switch").strip().lower() in CommonUtil.Affirmative_words:
1632+
autoit.win_activate(NameS)
16311633
return MainWindowElement
16321634
else:
16331635
found_windows.append(MainWindowElement)
16341636
except:
16351637
pass
16361638
if len(found_windows) > 0:
16371639
CommonUtil.ExecLog(sModuleInfo, "Switching to window: %s" % found_windows[0].Current.Name, 1)
1638-
autoit.win_activate(found_windows[0].Current.Name)
1640+
if Shared_Resources.Get_Shared_Variables("zeuz_window_auto_switch").strip().lower() in CommonUtil.Affirmative_words:
1641+
autoit.win_activate(found_windows[0].Current.Name)
16391642
return found_windows[0]
16401643
return None
16411644
except Exception:

Framework/MainDriverApi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ def set_important_variables():
829829
"num": advanced_float,
830830
"urlparse": urlparse,
831831
})
832+
shared.Set_Shared_Variables("zeuz_window_auto_switch", "on")
832833

833834
except:
834835
CommonUtil.Exception_Handler(sys.exc_info())

Framework/Utilities/CommonUtil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
upload_on_fail = True
124124
rerun_on_fail = True
125125
passed_after_rerun = False
126-
Affirmative_words = ("yes", "true", "ok", "enable")
126+
Affirmative_words = ("yes", "true", "ok", "enable", "on")
127127

128128
runid_index = 0
129129
tc_index = 0

0 commit comments

Comments
 (0)