Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the modal test, resolved #126 Issue #128

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

omkarkhatavkar
Copy link

@omkarkhatavkar omkarkhatavkar commented Nov 5, 2020

Fixed #126

Test Result

========================================================= test session starts ==========================================================
platform linux -- Python 3.7.3, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py37/.pytest_cache
rootdir: /home/okhatavk/Learning/widgetastic.patternfly
plugins: httpserver-0.3.6, cov-2.10.1, allure-pytest-2.8.19
collected 100 items / 99 deselected / 1 selected                                                                                       

testing/test_modal.py 
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================================== 1 passed, 99 deselected, 1 warning in 92.26s (0:01:32) ========================================

_

@omkarkhatavkar omkarkhatavkar changed the title fixed the modal test fixed the modal test, resolved #126 Nov 5, 2020
@omkarkhatavkar omkarkhatavkar changed the title fixed the modal test, resolved #126 fixed the modal test, resolved #126 Issue Nov 5, 2020
@omkarkhatavkar
Copy link
Author

Travis Issue fixed in PR #127

View.__init__(self, parent, logger=logger)

def __locator__(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In View or Widget when we set ROOT locator should auto-resolve.

I think it will be great if we fallow an approach like

ROOT = ParametrizedLocator("{@locator}")
def __init__(self, parent, id=None, logger=None):
    self.id = id
    if id:
        self.locator = <some_loator_with id>
    else:
        self.locator = <default>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think implementing __locator__ here is okay, though the pattern @digitronik suggested above does it without implementing the dunder method.

Why its broken in the first place, and why this fix works, is because of the WidgetMetaclass behavior in __new__.

Before the WidgetDescriptor instance is created when the unit test is defining the test view class, WidgetMetaclass is setting __locator__ based on the presence of ROOT in the kwargs. After this, when the WidgetDescriptor resolves into a View instance in the presence of a browser, self.ROOT is modified - but self.__locator__ has already been created automatically based off of the original definition.

def __locator__(self):
"""If id was passed, parametrize it into a locator, otherwise use ROOT"""
if self.id is not None:
return ('//div[normalize-space(@id)="{}" and contains(@class, "modal")'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please continue to use ParametrizedLocator here, its handling the injection of self.id into the string. No need to use format here, that part shouldn't change.

Copy link
Collaborator

@mshriver mshriver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See specific comments please, sorry for massive delay on review.

@mshriver mshriver marked this pull request as draft February 14, 2022 22:50
@mshriver
Copy link
Collaborator

@omkarkhatavkar keep an eye here: https://github.com/RedHatQE/widgetastic.patternfly/pull/132/files

I added a skip for this test so that I can see all passing, you can remove the skip in your branch if that gets merged before you make an update here. Otherwise I'll remove the skip marker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modal in unit test does not pass is_displayed
3 participants