Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.6
-
None
Description
i have a automation test step fail to open file since upgraded from version 5.15.2 to 5.15.6.
The test clicks "open folder" button (success) then the dialog just stays there forever.
At working version 5.15.2 , the test log captured
aspilog.reportComment("QFileDialog(Qt) found")
5.15.6 logs failed:
2023-03-29 17:55:25.757 5 [CLUSTER_LINE] wait 20
2023-03-29 17:55:25.840 5 [ACTIONWORD] wait 20
2023-03-29 17:55:25.840 5 [REPORT_COMMENT] waiting 20
2023-03-29 17:55:46.658 6 [CLUSTER_LINE] FileDialog.openFile Open Saved Test Items C:\Program Files\TestProgram\TEST\1.22.3.48887/scripts/Rec/STD/TestFiles/TestList_Default_HIGH.xml
2023-03-29 17:55:46.750 6 [ACTIONWORD] FileDialog.openFile Open Saved Test Items C:\Program Files\TestProgram\TEST\1.22.3.48887/scripts/Rec/STD/TestFiles/TestList_Default_HIGH.xml
2023-03-29 17:56:22.292 6 [REPORT_ERROR] [ERROR] Exception <class 'aspi.qttest.WindowNotFoundError'>,
Below is the script and class:
Script
test case Debug OpenTestStoreFullView TabBar.selectByToolTip Test Store qt_tabwidget_tabbar &memlist_tooltip LaunchPopup TOOLBUTTON Widget:Test Store FileOpen_action_button Open Saved Test Items wait 20 FileDialog.openFile Open Saved Test Items C:\Program Files\TestProgram\TEST\1.22.3.48887/scripts/Rec/STD/TestFiles/TestList_Default_HIGH.xml if &input == TEST ToolButton.click Widget:Frequency Store Export_action_button wait 10 end if CloseTestStore
Class
class FileDialog(Widget) : classname = "QFileDialog" @classmethod def openFile(clss, window, widget, item = "") : if item != "" : waitForWindow(window, 2) if os.path.isfile(item) : activate(window, widget, item) else : aspilog.reportError(item + " doesn't exist.") try : activate(window, "Cancel") except qttest.WidgetNotFoundError : activate(window, "Cancel_dialog_button") else : # for a native windows implementation of QFileDialog if Application.getContext() == None : raise ApplicationNotDefinedError else : item = widget import pywinauto # On a VMware virtual machine the code works successfully only if the file dialog window # is fully assembled. We will wait 5 seconds. time.sleep(5) item = os.path.normpath(item) app = pywinauto.application.Application() app.connect(process = Application.getContext().pid()) # for a native file dialog implementation the class name of the dialog box is #32770 # for a Qt4 file dialog implementation the class name of the dialog box is QWidget # for a Qt5 file dialog implementation the class name of the dialog box is Qt5QWindowIcon # for a Qt5.15.2 file dialog implementation the class name of the dialog box is Qt5152QWindowIcon win = app.window_(title=str(window), class_name_re='QWidget|Qt5QWindowIcon|Qt5152QWindowIcon|#32770', visible_only=True) try : win.Wait('ready', timeout=180) except pywinauto.timings.TimeoutError : raise qttest.WindowNotFoundError if win.FriendlyClassName() not in ('QWidget', 'Qt5QWindowIcon', 'Qt5152QWindowIcon') : # the native windows implementation of the QFileDialog is used aspilog.reportComment("QFileDialog(native) found") for i in range(120) : win.Edit.SetFocus() win.Edit.SetEditText(item) time.sleep(1) if win.Edit.TextBlock() == str(item) : break if os.path.isfile(item) : win.Button.SetFocus() win.Button.ClickInput() else : win.Cancel.SetFocus() win.Cancel.ClickInput() aspilog.reportError(item + " doesn't exist.") else : # the Qt implementation of the QFileDialog is used aspilog.reportComment("QFileDialog(Qt) found") try : if os.path.isfile(item) : LineEdit.enterText(window, "fileNameEdit", item) else : aspilog.reportError(item + " doesn't exist.") # close the file dialog try : PushButton.click(window, "Cancel") except qttest.WidgetNotFoundError : PushButton.click(window, "Cancel_dialog_button") except : aspilog.reportError("Could not enter file name") # close the file dialog try : PushButton.click(window, "Cancel") except qttest.WidgetNotFoundError : PushButton.click(window, "Cancel_dialog_button") # the file dialog should now be closed try : win.WaitNot('visible', timeout=30) aspilog.reportComment("FileDialog closed") except pywinauto.timings.TimeoutError : aspilog.reportError("FileDialog not closed") @classmethod def saveFile(clss, window, widget, item = "") : if item != "" : try : os.remove(item) except : pass waitForWindow(window, 2) activate(window, widget, item) else : # for a native windows implementation of QFileDialog if Application.getContext() == None : raise ApplicationNotDefinedError else : item = widget import pywinauto try : os.remove(item) except : pass # On a VMware virtual machine the code works successfully only if the file dialog window # is fully assembled. We will wait 5 seconds. time.sleep(5) item = os.path.normpath(item) app = pywinauto.application.Application() app.connect(process = Application.getContext().pid()) # for a native file dialog implementation the class name of the dialog box is #32770 # for a Qt4 file dialog implementation the class name of the dialog box is QWidget # for a Qt5 file dialog implementation the class name of the dialog box is Qt5QWindowIcon # for a Qt5.15.2 file dialog implementation the class name of the dialog box is Qt5152QWindowIcon win = app.window_(title=str(window), class_name_re='QWidget|Qt5QWindowIcon|Qt5152QWindowIcon|#32770', visible_only=True) try : win.Wait('ready', timeout=180) except pywinauto.timings.TimeoutError : raise qttest.WindowNotFoundError if win.FriendlyClassName() not in ('QWidget', 'Qt5QWindowIcon', 'Qt5152QWindowIcon') : # the native windows implementation of the QFileDialog is used aspilog.reportComment("QFileDialog(native) found") for i in range(120) : win.Edit.SetFocus() win.Edit.SetEditText(item) time.sleep(1) if win.Edit.TextBlock() == str(item) : break win.Button.SetFocus() win.Button.ClickInput() else : # the Qt implementation of the QFileDialog is used aspilog.reportComment("QFileDialog(Qt) found") try : LineEdit.enterText(window, "fileNameEdit", item) except : aspilog.reportError("Could not enter file name") # close the file dialog try : PushButton.click(window, "Cancel") except qttest.WidgetNotFoundError : PushButton.click(window, "Cancel_dialog_button") # the file dialog should now be closed try : win.WaitNot('visible', timeout=30) aspilog.reportComment("FileDialog closed") except pywinauto.timings.TimeoutError : aspilog.reportError("FileDialog not closed") @classmethod def setTypeFilter(clss, window, value = "") : if Application.getContext() == None : raise ApplicationNotDefinedError else : import pywinauto app = pywinauto.application.Application() app.connect(process = Application.getContext().pid()) # for a native file dialog implementation the class name of the dialog box is #32770 # for a Qt4 file dialog implementation the class name of the dialog box is QWidget # for a Qt5 file dialog implementation the class name of the dialog box is Qt5QWindowIcon # for a Qt5.15.2 file dialog implementation the class name of the dialog box is Qt5152QWindowIcon win = app.window_(title=str(window), class_name_re='QWidget|Qt5QWindowIcon|Qt5152QWindowIcon|#32770', visible_only=True) try : win.Wait('ready', timeout=180) except pywinauto.timings.TimeoutError : raise qttest.WindowNotFoundError if win.FriendlyClassName() not in ('QWidget', 'Qt5QWindowIcon', 'Qt5152QWindowIcon') : # the native windows implementation of the QFileDialog is used aspilog.reportComment("QFileDialog(native) found") win.ComboBox2.SetFocus() try : win.ComboBox2.Select(value) win.ComboBox2.Class() except ValueError : aspilog.reportError(value + " not found, entries are " + str(win.ComboBox2.ItemTexts())) else : # the Qt implementation of the QFileDialog is used aspilog.reportComment("QFileDialog(Qt) found") ComboBox.activateText(window, "fileTypeCombo", value) @classmethod def checkTypeFilter(clss, window, value = "") : if Application.getContext() == None : raise ApplicationNotDefinedError else : import pywinauto app = pywinauto.application.Application() app.connect(process = Application.getContext().pid()) # for a native file dialog implementation the class name of the dialog box is #32770 # for a Qt4 file dialog implementation the class name of the dialog box is QWidget # for a Qt5 file dialog implementation the class name of the dialog box is Qt5QWindowIcon # for a Qt5.15.2 file dialog implementation the class name of the dialog box is Qt5152QWindowIcon win = app.window_(title=str(window), class_name_re='QWidget|Qt5QWindowIcon|Qt5152QWindowIcon|#32770', visible_only=True) try : win.Wait('ready', timeout=180) except pywinauto.timings.TimeoutError : raise qttest.WindowNotFoundError if win.FriendlyClassName() not in ('QWidget', 'Qt5QWindowIcon', 'Qt5152QWindowIcon') : # the native windows implementation of the QFileDialog is used aspilog.reportComment("QFileDialog(native) found") if value != win.ComboBox2.WindowText() : aspilog.reportError(win.ComboBox2.windowText()) else : # the Qt implementation of the QFileDialog is used aspilog.reportComment("QFileDialog(Qt) found") ComboBox.checkProperty(window, "fileTypeCombo", "currentText", value)