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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悰 Bug]: url_matches expected condition is using re.search possibly accidentally #11431

Closed
symonk opened this issue Dec 15, 2022 · 2 comments

Comments

@symonk
Copy link
Member

symonk commented Dec 15, 2022

What happened?

According to the docstring of url_matches the pattern should be matched against the url exactly - Is a re.search sufficient here over re.fullmatch ?

    """An expectation for checking the current url.
    pattern is the expected pattern, which must be an exact match
    returns True if the url matches, false otherwise.
    """

This may be as expected, either way we should either update the docstring if the current searching is adequate, or move to re.fullmatch maybe if the implementation is slightly off?

theres also a url_to_be that relies on string equality, which is slightly less usable for polling against dynamic aspects of a url, so the docstring might just of been a copy-paste mistake there.

Will take a look at other bindings if they implement EC in this particular use case (if at all - not sure if ec was removed from some or if that was mostly talk at the time)

How can we reproduce the issue?

from selenium import webdriver
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait


with webdriver.Chrome() as driver:
    driver.get("https://www.selenium.dev")
    # matches on first iteration
    _ = WebDriverWait(driver, timeout=30).until(expected_conditions.url_matches(pattern="dev"))

Relevant log output

Not Applicable.

Operating System

N/A

Selenium version

4.7.2

What are the browser(s) and version(s) where you see this issue?

Not Applicable.

What are the browser driver(s) and version(s) where you see this issue?

Not Applicable.

Are you using Selenium Grid?

Not Applicable.

@github-actions
Copy link

@symonk, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@symonk
Copy link
Member Author

symonk commented Dec 19, 2022

quick look at the java code that relies on pattern.matcher(url).find(); which I think finds the first occurrence anywhere in the string? (similar to pythons re.search(...)

@symonk symonk closed this as completed in 9a30730 Dec 21, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants