chore: attempt to fix AttributeError: Attempt to access a property of a null object
This commit is contained in:
parent
9b11caf5a2
commit
72c721af04
|
@ -450,20 +450,37 @@ class PermissionsSettingsView(QObject):
|
||||||
self._is_allowed_to_edit_tag = QObject(names.isAllowedToEditPermissionView_StatusListItemTag)
|
self._is_allowed_to_edit_tag = QObject(names.isAllowedToEditPermissionView_StatusListItemTag)
|
||||||
|
|
||||||
@allure.step('Get titles of Who holds tags')
|
@allure.step('Get titles of Who holds tags')
|
||||||
def get_who_holds_tags_titles(self) -> typing.List[str]:
|
def get_who_holds_tags_titles(self, attempt: int = 2) -> typing.List[str]:
|
||||||
who_holds_tags = [str(tag.title) for tag in driver.findAllObjects(self._who_holds_tag.real_name)]
|
try:
|
||||||
return who_holds_tags
|
return [str(tag.title) for tag in driver.findAllObjects(self._who_holds_tag.real_name)]
|
||||||
|
except AttributeError as er:
|
||||||
|
if attempt:
|
||||||
|
time.sleep(1)
|
||||||
|
return self.get_who_holds_tags_titles(attempt - 1)
|
||||||
|
else:
|
||||||
|
raise er
|
||||||
|
|
||||||
@allure.step('Get titles of Is Allowed tags')
|
@allure.step('Get titles of Is Allowed tags')
|
||||||
def get_is_allowed_tags_titles(self) -> typing.List[str]:
|
def get_is_allowed_tags_titles(self, attempt: int = 2) -> typing.List[str]:
|
||||||
is_allowed_tags = [str(tag.title) for tag in driver.findAllObjects(self._is_allowed_tag.real_name)]
|
try:
|
||||||
return is_allowed_tags
|
return [str(tag.title) for tag in driver.findAllObjects(self._is_allowed_tag.real_name)]
|
||||||
|
except AttributeError as er:
|
||||||
|
if attempt:
|
||||||
|
time.sleep(1)
|
||||||
|
return self.get_is_allowed_tags_titles(attempt - 1)
|
||||||
|
else:
|
||||||
|
raise er
|
||||||
|
|
||||||
@allure.step('Get title of inCommunity tag')
|
@allure.step('Get title of inCommunity tag')
|
||||||
def get_in_community_in_channel_tags_titles(self) -> typing.List[str]:
|
def get_in_community_in_channel_tags_titles(self, attempt: int = 2) -> typing.List[str]:
|
||||||
in_community_in_channel_tags = [str(tag.title) for tag in
|
try:
|
||||||
driver.findAllObjects(self._in_community_in_channel_tag.real_name)]
|
return [str(tag.title) for tag in driver.findAllObjects(self._in_community_in_channel_tag.real_name)]
|
||||||
return in_community_in_channel_tags
|
except AttributeError as er:
|
||||||
|
if attempt:
|
||||||
|
time.sleep(1)
|
||||||
|
return self.get_in_community_in_channel_tags_titles(attempt - 1)
|
||||||
|
else:
|
||||||
|
raise er
|
||||||
|
|
||||||
@allure.step('Set state of who holds checkbox')
|
@allure.step('Set state of who holds checkbox')
|
||||||
def set_who_holds_checkbox_state(self, state):
|
def set_who_holds_checkbox_state(self, state):
|
||||||
|
|
|
@ -2,6 +2,7 @@ import allure
|
||||||
import pytest
|
import pytest
|
||||||
from allure_commons._allure import step
|
from allure_commons._allure import step
|
||||||
|
|
||||||
|
import configs
|
||||||
from gui.components.changes_detected_popup import PermissionsChangesDetectedToastMessage
|
from gui.components.changes_detected_popup import PermissionsChangesDetectedToastMessage
|
||||||
from gui.components.delete_popup import DeletePermissionPopup
|
from gui.components.delete_popup import DeletePermissionPopup
|
||||||
from gui.components.toast_message import ToastMessage
|
from gui.components.toast_message import ToastMessage
|
||||||
|
@ -62,16 +63,21 @@ def test_add_edit_and_remove_permissions(main_screen: MainWindow, params, checkb
|
||||||
|
|
||||||
with step('Created permission is displayed on permission page'):
|
with step('Created permission is displayed on permission page'):
|
||||||
if asset_title is not False:
|
if asset_title is not False:
|
||||||
assert driver.waitFor(lambda: asset_title in permissions_settings.get_who_holds_tags_titles())
|
assert driver.waitFor(lambda: asset_title in permissions_settings.get_who_holds_tags_titles(),
|
||||||
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||||
if second_asset_title is not False:
|
if second_asset_title is not False:
|
||||||
assert driver.waitFor(lambda: second_asset_title in permissions_settings.get_who_holds_tags_titles())
|
assert driver.waitFor(lambda: second_asset_title in permissions_settings.get_who_holds_tags_titles(),
|
||||||
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||||
if allowed_to_title is not False:
|
if allowed_to_title is not False:
|
||||||
assert driver.waitFor(lambda: allowed_to_title in permissions_settings.get_is_allowed_tags_titles())
|
assert driver.waitFor(lambda: allowed_to_title in permissions_settings.get_is_allowed_tags_titles(),
|
||||||
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||||
if in_channel is False:
|
if in_channel is False:
|
||||||
assert driver.waitFor(
|
assert driver.waitFor(
|
||||||
lambda: params['name'] in permissions_settings.get_in_community_in_channel_tags_titles())
|
lambda: params['name'] in permissions_settings.get_in_community_in_channel_tags_titles(),
|
||||||
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||||
if in_channel:
|
if in_channel:
|
||||||
assert driver.waitFor(lambda: in_channel in permissions_settings.get_in_community_in_channel_tags_titles())
|
assert driver.waitFor(lambda: in_channel in permissions_settings.get_in_community_in_channel_tags_titles(),
|
||||||
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||||
|
|
||||||
with step('Edit permission'):
|
with step('Edit permission'):
|
||||||
edit_permission_view = permissions_intro_view.open_edit_permission_view()
|
edit_permission_view = permissions_intro_view.open_edit_permission_view()
|
||||||
|
@ -88,14 +94,14 @@ def test_add_edit_and_remove_permissions(main_screen: MainWindow, params, checkb
|
||||||
changes_popup.update_permission()
|
changes_popup.update_permission()
|
||||||
if allowed_to is 'becomeAdmin' and checkbox_state is True:
|
if allowed_to is 'becomeAdmin' and checkbox_state is True:
|
||||||
if asset_title is not False:
|
if asset_title is not False:
|
||||||
assert driver.waitFor(lambda: asset_title not in permissions_settings.get_who_holds_tags_titles())
|
assert driver.waitFor(lambda: asset_title not in permissions_settings.get_who_holds_tags_titles(), configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||||
if second_asset_title is not False:
|
if second_asset_title is not False:
|
||||||
assert driver.waitFor(
|
assert driver.waitFor(
|
||||||
lambda: second_asset_title not in permissions_settings.get_who_holds_tags_titles())
|
lambda: second_asset_title not in permissions_settings.get_who_holds_tags_titles(), configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||||
elif checkbox_state is False:
|
elif checkbox_state is False:
|
||||||
assert driver.waitFor(lambda: 'Become member' in permissions_settings.get_is_allowed_tags_titles())
|
assert driver.waitFor(lambda: 'Become member' in permissions_settings.get_is_allowed_tags_titles(), configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||||
else:
|
else:
|
||||||
assert driver.waitFor(lambda: permissions_intro_view.is_hide_icon_visible)
|
assert driver.waitFor(lambda: permissions_intro_view.is_hide_icon_visible, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||||
|
|
||||||
with step('Check toast message for edited permission'):
|
with step('Check toast message for edited permission'):
|
||||||
messages = ToastMessage().get_toast_messages
|
messages = ToastMessage().get_toast_messages
|
||||||
|
|
Loading…
Reference in New Issue