-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[🐛 Bug]: wait.until is not usable #10606
Comments
@Clairwai, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
FYI, I can run the same project in my window computer and Mac with Intel CPU. Thanks. |
Hi, @Clairwai. Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue. Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough. Reply to this issue when all information is provided, thank you. |
Can you please provide a GitHub repository with a sample project we can clone to reproduce the issue? |
ExpectedCondition used to extend Guava, but no longer does, so those fixes are old. I suspect that you have a dependency issue on the machine that is having the problem. Please investigate: https://www.javaadvent.com/2020/12/how-to-debug-dependency-conflicts-in-maven-and-gradle.html My preferred recommendation is to switch to using the lambdas directly, especially if you are wrapping them in methods like this: public void visibilityOfElementLocatedByXpath(String xpath){
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.withMessage("waiting for visibility of element located with By.xpath: " + xpath)
.until(d -> d.findElement(By.xpath(xpath)).isDisplayed());
} |
Closing as we did not get more information. |
To reproduce this, it depends on the guava version you are using. I just ran across this in a project that has guava 25.1-android. The package com.google.common.base;
public interface Function<F, T> {
T apply(@NullableDecl F input);
} But compare that to the non-android version which looks like this: package com.google.common.base;
public interface Function<F, T> extends java.util.function.Function<F, T> {
T apply(@NullableDecl F input);
} To work around it, you can wrap your expected conditions in a custom method defined as: public static <T> Function<? super WebDriver, T> toFunc(ExpectedCondition<T> expectedCondition) {
return expectedCondition::apply;
} And usage would then need to be something like: new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(2))
.until(toFunc(visibilityOf(menuOptions))) Or use a different version of guava. Ideally, the |
@ammmze what version of Selenium is this? We shouldn't be depending on Guava any longer. |
We started seeing this when I just did an upgrade from 3.x to 4.1.4. The dependency is here. |
But FWIW, I still see lots of stuff pulling in guava stuff. |
Welp, I either misread a while back or missed entirely the note on that page for why Selenium uses the Guava Function instead of the Java one. I still have a lot to learn about our Java code. :) Thanks for the explanation. |
No worries! I think we should be able to resolve this issue as well as keep the guava functionality if we just update the public interface ExpectedCondition<T> extends Function<WebDriver, T> {} to be: public interface ExpectedCondition<T> extends Function<WebDriver, T>, java.util.function.Function<WebDriver, T> {} This should allow it to work with the versions of guava that don't extend the java native |
@ammmze would you mind making a PR with the proposed fix? Not sure how easy it'll be to test. |
@titusfortner I'm not sure there is a feasible way to test it 🤷🏻♂️ but here's that pr. |
Reading the comments in
I wonder how much users' code we would break if we switch to the Java |
Yea...if this was for the 4.0.0 release, I think it would have been fine to entirely swap to the java native one as that would have been a breaking change in that regard. The effect of just simply adding the java native com.google.common.base.Function condition = ExpectedConditions.elementFound(By); java.util.function.Function condition = ExpectedConditions.elementFound(By); |
@ammmze do you know if the exception below happens at compile time or at run time?
|
Hmm...I'm not 100% sure. I would guess compile time. Most type issues with java are caught at compile time. Did you trigger this error somewhere? |
It is in the original comment. |
Oh right...yea...the issue we were seeing here was compile time. So before this was fixed we couldn't compile successfully. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What happened?
My "wait.until" function worked fine yesterday, but all a sudden now is not runnable.
Error message: reason: no instance(s) of type variable(s) V exist so that ExpectedCondition conforms to Function<? super WebDriver, V>
I have looked it up online, and people said it is related to the inconsistent versions of Guava and Selenium. However, I have already checked my project structure, and there are no other extra versions of Guava and Selenium.
How can we reproduce the issue?
I am not sure how to reproduce since I don't know what's wrong.
The only thing I can provide is what I am using. Sorry and thanks.
Please see my pom.xml below:
The code I have run:
In addition, I am using JAVA 17, maven project with IntelliJ IDEA with MacBook Air (M1,2020).
Operating System
MacBook Air (M1,2020) - macOS Monterey 12.2.1
Selenium version
4.1.3
What are the browser(s) and version(s) where you see this issue?
Not-related
What are the browser driver(s) and version(s) where you see this issue?
Not-related
Are you using Selenium Grid?
No
The text was updated successfully, but these errors were encountered: