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

UI tests in test_pvc_ui.py fails due to selenium.common.exceptions.TimeoutException: Message: Failed to find the element #9794

Closed
sidhant-agrawal opened this issue May 11, 2024 · 0 comments · Fixed by #9795
Assignees

Comments

@sidhant-agrawal
Copy link
Contributor

UI tests in test_pvc_ui.py are failing in 4.15 and 4.16 runs with below error message:

Error message:

selenium.common.exceptions.TimeoutException: Message: Failed to find the element (xpath,//button[(@class='pf-c-dropdown__menu-item' or @class='pf-v5-c-dropdown__menu-item') and contains(text(), 'With Form')])

Stack Trace:

_locator = ("//button[(@class='pf-c-dropdown__menu-item' or @class='pf-v5-c-dropdown__menu-item') and contains(text(), 'With Form')]", 'xpath')
_timeout = 30, _enable_screenshot = False, _copy_dom = False

    def _do_click(_locator, _timeout=30, _enable_screenshot=False, _copy_dom=False):
        # wait for page fully loaded only if an element was not located
        # prevents needless waiting and frequent crushes on ODF Overview page,
        # when metrics and alerts frequently updated
        if not self.get_elements(_locator):
            self.page_has_loaded()
        screenshot = (
            ocsci_config.UI_SELENIUM.get("screenshot") and enable_screenshot
        )
        if screenshot:
            self.take_screenshot()
        if _copy_dom:
            self.copy_dom()
    
        wait = WebDriverWait(self.driver, timeout)
        try:
            if (
                version.get_semantic_version(get_ocp_version(), True)
                <= version.VERSION_4_11
            ):
                element = wait.until(
                    ec.element_to_be_clickable((locator[1], locator[0]))
                )
            else:
>               element = wait.until(
                    ec.visibility_of_element_located((locator[1], locator[0]))
                )

ocs_ci/ocs/ui/base_ui.py:202: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <selenium.webdriver.support.wait.WebDriverWait (session="2d9b665422ae762775c3b0aa613027ab")>
method = <selenium.webdriver.support.expected_conditions.visibility_of_element_located object at 0x7f1152c277f0>
message = ''

    def until(self, method, message=''):
        """Calls the method provided with the driver as an argument until the \
        return value is not False."""
        screen = None
        stacktrace = None
    
        end_time = time.time() + self._timeout
        while True:
            try:
                value = method(self._driver)
                if value:
                    return value
            except self._ignored_exceptions as exc:
                screen = getattr(exc, 'screen', None)
                stacktrace = getattr(exc, 'stacktrace', None)
            time.sleep(self._poll)
            if time.time() > end_time:
                break
>       raise TimeoutException(message, screen, stacktrace)
E       selenium.common.exceptions.TimeoutException: Message:

venv/lib64/python3.9/site-packages/selenium/webdriver/support/wait.py:80: TimeoutException

During handling of the above exception, another exception occurred:

self = <tests.functional.ui.test_pvc_ui.TestPvcUserInterface object at 0x7f1171ad0730>
project_factory = <function project_factory_fixture.<locals>.factory at 0x7f115a32e160>
teardown_factory = <function teardown_factory_fixture.<locals>.factory at 0x7f115a32e040>
setup_ui_class = <selenium.webdriver.chrome.webdriver.WebDriver (session="2d9b665422ae762775c3b0aa613027ab")>
sc_name = 'ocs-storagecluster-cephfs', access_mode = 'ReadWriteMany'
pvc_size = '2', vol_mode = 'Filesystem'

    @tier1
    @pytest.mark.parametrize(
        argnames=["sc_name", "access_mode", "pvc_size", "vol_mode"],
        argvalues=[
            pytest.param(
                "ocs-storagecluster-cephfs",
                "ReadWriteMany",
                "2",
                "Filesystem",
                marks=pytest.mark.polarion_id("OCS-5210"),
            ),
            pytest.param(
                "ocs-storagecluster-ceph-rbd",
                "ReadWriteMany",
                "3",
                "Block",
                marks=pytest.mark.polarion_id("OCS-5211"),
            ),
            pytest.param(
                "ocs-storagecluster-cephfs",
                "ReadWriteOnce",
                "10",
                "Filesystem",
                marks=pytest.mark.polarion_id("OCS-5212"),
            ),
            pytest.param(
                *["ocs-storagecluster-ceph-rbd", "ReadWriteOnce", "11", "Block"],
                marks=[skipif_ocs_version("<4.7"), pytest.mark.polarion_id("OCS-5206")],
            ),
            pytest.param(
                "ocs-storagecluster-ceph-rbd",
                "ReadWriteOnce",
                "13",
                "Filesystem",
                marks=pytest.mark.polarion_id("OCS-5207"),
            ),
        ],
    )
    def test_create_resize_delete_pvc(
        self,
        project_factory,
        teardown_factory,
        setup_ui_class,
        sc_name,
        access_mode,
        pvc_size,
        vol_mode,
    ):
        """
        Test create, resize and delete pvc via UI
    
        """
        # Creating a test project via CLI
        pro_obj = project_factory()
        project_name = pro_obj.namespace
    
        pvc_ui_obj = PvcUI()
    
        # Creating PVC via UI
        pvc_name = create_unique_resource_name("test", "pvc")
    
        if config.DEPLOYMENT["external_mode"]:
            if sc_name == constants.CEPHFILESYSTEM_SC:
                sc_name = constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_CEPHFS
            elif sc_name == constants.CEPHBLOCKPOOL_SC:
                sc_name = constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD
    
>       pvc_ui_obj.create_pvc_ui(
            project_name, sc_name, pvc_name, access_mode, pvc_size, vol_mode
        )

tests/functional/ui/test_pvc_ui.py:101: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
ocs_ci/ocs/ui/pvc_ui.py:46: in create_pvc_ui
    self.do_click(self.pvc_loc["create_pvc_dropdown_item"])
ocs_ci/ocs/ui/base_ui.py:215: in do_click
    _do_click(locator, timeout, enable_screenshot, copy_dom)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

_locator = ("//button[(@class='pf-c-dropdown__menu-item' or @class='pf-v5-c-dropdown__menu-item') and contains(text(), 'With Form')]", 'xpath')
_timeout = 30, _enable_screenshot = False, _copy_dom = False

    def _do_click(_locator, _timeout=30, _enable_screenshot=False, _copy_dom=False):
        # wait for page fully loaded only if an element was not located
        # prevents needless waiting and frequent crushes on ODF Overview page,
        # when metrics and alerts frequently updated
        if not self.get_elements(_locator):
            self.page_has_loaded()
        screenshot = (
            ocsci_config.UI_SELENIUM.get("screenshot") and enable_screenshot
        )
        if screenshot:
            self.take_screenshot()
        if _copy_dom:
            self.copy_dom()
    
        wait = WebDriverWait(self.driver, timeout)
        try:
            if (
                version.get_semantic_version(get_ocp_version(), True)
                <= version.VERSION_4_11
            ):
                element = wait.until(
                    ec.element_to_be_clickable((locator[1], locator[0]))
                )
            else:
                element = wait.until(
                    ec.visibility_of_element_located((locator[1], locator[0]))
                )
            element.click()
        except TimeoutException as e:
            self.take_screenshot()
            self.copy_dom()
            logger.error(e)
>           raise TimeoutException(
                f"Failed to find the element ({locator[1]},{locator[0]})"
            )
E           selenium.common.exceptions.TimeoutException: Message: Failed to find the element (xpath,//button[(@class='pf-c-dropdown__menu-item' or @class='pf-v5-c-dropdown__menu-item') and contains(text(), 'With Form')])

ocs_ci/ocs/ui/base_ui.py:210: TimeoutException
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant