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

Fix _find_by_data_locator #1924

Merged
merged 1 commit into from
Nov 2, 2024
Merged

Conversation

markus-leben
Copy link
Contributor

@markus-leben markus-leben commented Oct 7, 2024

Off by one in _find_by_data_locator which causes opaque failure on data values which contain a colon.

Example html:
<div data-automation-id="foo:bar">This might be trouble</div>

Example robot:
Scroll Element Into View data:automation-id:foo:bar

Error message:
Provided selector (automation-id:foo:bar) is malformed. Correct format: name:value.

I don't love the person putting colons in their automation ID, but we don't always get to choose the html we're testing.

Fixed off by one in _find_by_data_locator
@emanlove emanlove self-assigned this Oct 7, 2024
@emanlove emanlove added this to the Oct 2024 milestone Oct 7, 2024
@markus-leben
Copy link
Contributor Author

On second thought it might be a good idea to also change the error raised in the try or the message given in the except. The error that gets caught by that catch is a ValueError about unpacking with string's split() method:
ValueError: too many values to unpack (expected 2)

But the error message from the except in _find_by_data_locator catches that ValueError and replaces it with something that's in this case more vague, and implies that the reason the ValueError is raised is because of the condition in the try, rather than an unrelated ValueError.

I'm not sure what the ideal fix here would be though.

@emanlove emanlove added bug in progress priority: high acknowledge To be acknowledged in release notes and removed needs review labels Nov 2, 2024
@emanlove
Copy link
Member

emanlove commented Nov 2, 2024

I have some unit tests to verify this change which I will submit in another PR.

@emanlove emanlove merged commit 96fa446 into robotframework:master Nov 2, 2024
0 of 48 checks passed
emanlove added a commit to emanlove/robotframework-seleniumlibrary that referenced this pull request Nov 2, 2024
emanlove added a commit to emanlove/robotframework-seleniumlibrary that referenced this pull request Nov 2, 2024
Added a couple unit tests to verify markus-leben's fix (robotframework#1924) for
allowing colons within the value of the data locator.
emanlove added a commit that referenced this pull request Nov 2, 2024
@emanlove emanlove modified the milestones: Oct 2024, v6.7.0 Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledge To be acknowledged in release notes bug priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants