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

Add quotes escaper method #106

Merged
merged 2 commits into from
Jan 31, 2025
Merged

Conversation

QuirrelForU
Copy link
Contributor

Looks like for now there is some issue with pomcorn XpathLocators.

For example if I want to create a locator

locators.ElementWithTextLocator(
        text="He is choosing beetwen \"pancakes\" and 'waffles'", exact=True
    )

I'll get this query:

//*[./text()="He is choosing beetwen "pancakes" and 'waffles'"]

but it won't work
image

Current implementation can handle this cases and we get

//*[./text()=concat("He is choosing between ", '"', "pancakes", '"', " and ", "'", "waffles", "'")]

image

@QuirrelForU QuirrelForU self-assigned this Jan 30, 2025
@QuirrelForU QuirrelForU force-pushed the feature/locator-quotes-escaping branch from 488bd6b to e99064e Compare January 30, 2025 08:45
@QuirrelForU QuirrelForU marked this pull request as ready for review January 30, 2025 09:02
Comment on lines 159 to 161
@staticmethod
def _escape_quotes(text: str) -> str:
"""Escape single and double quotes in given text for use in locators. # noqa: D202, E501.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

noqa is used cuz for some reason flake tells that there is empty line 😕

pomcorn/locators/base_locators.py Outdated Show resolved Hide resolved
pomcorn/locators/base_locators.py Outdated Show resolved Hide resolved
pomcorn/component.py Outdated Show resolved Hide resolved
pomcorn/locators/base_locators.py Outdated Show resolved Hide resolved
Copy link
Contributor

@M1troll M1troll left a comment

Choose a reason for hiding this comment

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

Please update also version in pyproject.toml and changelog

@QuirrelForU QuirrelForU force-pushed the feature/locator-quotes-escaping branch from 5832119 to 4a96b25 Compare January 31, 2025 04:02
@QuirrelForU QuirrelForU requested a review from M1troll January 31, 2025 04:02
@QuirrelForU QuirrelForU merged commit 06164ed into main Jan 31, 2025
1 check passed
@QuirrelForU QuirrelForU deleted the feature/locator-quotes-escaping branch January 31, 2025 04:11
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.

4 participants