Skip to content

Chaining locators with lists does not work with Robot Framework 6.1 or above #1962

Description

@jjaakkola-atostek

Giving chained locator as a list of locators seems not to work since Robot Framework 6.1.0. Tested with Chrome and Firefox using test web page and test case given below. The first chained locator with >> finds the element, but latter with list does not . With Robot Framework 6.0.1 works fine. Tested also with RF 7.4.1 and not working.

I did some research in the SeleniumLibrary's code, and problem seems to be with the type annotations of the keywords. For example:

def click_element(
        self,
        locator: Union[WebElement, str],
        modifier: Union[bool, str] = False,
        action_chain: bool = False,
    ):

locator's type annotation should be `Union[WebElement, str, list]´. If I chance that, my test code passes.

Software and versions

SeleniumLibrary: 6.8.0
Robot Framework: 6.1 and 7.4.1
robotframework-pythonlibcore: 4.5.0
Python: 3.11.9
Chrome: 143.0.7499.171
ChromeDriver: 143.0.7499.40
Firefox: 147.0.1
Gecko Driver: 0.36.0

Example HTML

<html>
	<head>
		<title>Locator Chain Test</title>
	</head>
	<body>
		<button id="testElement">This is a test</button>
	</body>
</html>

Example test case

*** Settings ***
Library	SeleniumLibrary

*** Test Cases ***
Locator Chain Test
	Open Browser		[test_file_path]	chrome
	Click Element		tag:body >> id:testElement
	${locator_chain}	Create List	tag:body	id:testElement
	Click Element		${locator_chain}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions