There seems to be an issue with your code. It appears that the code is duplicated and there are syntax errors as well. Here's the corrected version:
python
def checkItemMenuEnable(self, itemName):
if squish.findObject(itemName).enabled:
test.log(f'Пункт меню {itemName} доступен')
else:
test.warning(f'Пункт меню {itemName} не найден')
def checkItemMenuDisable(self, itemName):
if not squish.findObject(itemName).enabled:
test.log(f'Пункт меню {itemName} недоступен')
else:
test.warning(f'Пункт меню {itemName} не найден')
In the corrected code, I removed the duplicated block of code and fixed the indentation and syntax errors. Please review and make any necessary adjustments.
User
def tapItemMenu(self,itemName):
elementMenu = qml.searchObj(squish.waitForObject(self.contentMenu), 'text', itemName)
if elementMenu:
squish.tapObject(elementMenu)
else:
test.warning(f'Пункт меню {itemName} не найден')
return
Type: CODE_SMELL CODE_SMELL
Severity: MINOR MINOR
Message: Remove this redundant return.
Duration (min): 1
Project ID: MT Issue ID: AYnkKokztFfdH6q1DHQh
Assistant
The linting tool is suggesting that you can remove the return statement from the else block in your code since it is not needed. Here's the updated code:
python
def tapItemMenu(self, itemName):
elementMenu = qml.searchObj(squish.waitForObject(self.contentMenu), 'text', itemName)
if elementMenu:
squish.tapObject(elementMenu)
else:
test.warning(f'Пункт меню {itemName} не найден')
By removing the return, the code will still function correctly.
User
по русски пожалуйста
Assistant
Линтинговый инструмент предлагает удалить ненужное выражение return из блока else в вашем коде. Вот обновленный код:
python
def tapItemMenu(self, itemName):
elementMenu = qml.searchObj(squish.waitForObject(self.contentMenu), 'text', itemName)
if elementMenu:
squish.tapObject(elementMenu)
else:
test.warning(f'Пункт меню {itemName} не найден')
Удаление return не повлияет на функциональность кода, и он продолжит работать правильно.
User
Assistant
Ошибка возникает потому, что у объекта ToolPanel нет атрибута toolbar. Скорее всего, это происходит из-за неправильной инициализации или использования объекта ToolPanel.
Проверьте, что у вас правильно создан и настроен объект ToolPanel, и убедитесь, что у него есть атрибут toolbar. Если необходимо, убедитесь, что вы правильно передаете значение переменной page в конструктор ToolPanel.
Если проблема сохраняется, рекомендуется проверить другие части вашего кода, связанные с инициализацией и использованием объекта ToolPanel, чтобы выяснить причину отсутствия атрибута toolbar.
Получаю ошибку
Detail AttributeError: 'ToolPanel' object has no attribute 'toolbar' (Screenshot in "/home/mishqm/.squish/Test Results/2023-08-13T01-08-39.259+02-00/1/suite_doc_with_started_visit/tst_merch/errorImages/error_1.png") /home/mishqm/Repos/mt/gui_tests/squish/global/scripts/base/tool_panel.py:237