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

FluentWait might never complete #7494

Closed
utamas opened this issue Aug 14, 2019 · 8 comments
Closed

FluentWait might never complete #7494

utamas opened this issue Aug 14, 2019 · 8 comments
Labels

Comments

@utamas
Copy link
Contributor

utamas commented Aug 14, 2019

🐛 Bug Report

When Function passed to until never returns then FluentWait never completes.

To Reproduce

  1. Set a timeout value (e.g.: 1 second),
  2. Pass in a function to until that takes more time then timeout value set in previous step (e.g.: 2 sec).

Expected behavior

FluentWait throws timeout exception after timeout value set for it has passed.

Test script or set of commands reproducing this issue

        long start = System.currentTimeMillis();
        String actual = new FluentWait<>(driver)
                .withTimeout(ofSeconds(1))
                .pollingEvery(ofMillis(450))
                .withMessage("I got bored waiting for this function to complete")
                .until($ -> {
                    try {
                        SECONDS.sleep(5);
                        return "I'm done";
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                });

        long end = System.currentTimeMillis();
        assert end - start < 2000;
@markwheeler700
Copy link

Happens for me as well

await driver.wait(until.elementLocated(By.css("some element"), 5000, 'Could not locate the element within the time specified'));

Never returns

@utamas
Copy link
Contributor Author

utamas commented Aug 15, 2019

Is this JS code?

@markwheeler700
Copy link

Yes JS code using webdriverjs https://www.npmjs.com/package/selenium-webdriver latest version ^4.0.0-alpha.4 with chrome driver latest version ^76.0.0
I'm running tests using Jest
The code will return ok if element is present but if element is not present then the test just hangs until it hits by Jest timeout, which is set at 60 seconds. But it should return after 5 seconds and fail with element not present. Looks like the timeout value in wait(until) does not work.

@utamas
Copy link
Contributor Author

utamas commented Aug 16, 2019

The issue I'm seeing is in a java client, so I'm fairly confident the two is unrelated. I'm not familiar with the JS client, so I can't really help you where to look, Sorry.

@barancev barancev added the C-java label Sep 1, 2019
@utamas
Copy link
Contributor Author

utamas commented Sep 10, 2019

Once I get some time, I would love to open a PR (have a working solution in our project) for fixing this.

utamas added a commit to utamas/selenium that referenced this issue Oct 16, 2019
FluentWait could potentially never complete when the condition
passed to it made no progress (either because it fall into an
infinite loop or waiting for a resource or response over
network).

Fixes SeleniumHQ#7494
utamas added a commit to utamas/selenium that referenced this issue Oct 16, 2019
Hanged is a dodgy expression.

Fixes SeleniumHQ#7494
@utamas
Copy link
Contributor Author

utamas commented Oct 16, 2019

#7692

utamas added a commit to utamas/selenium that referenced this issue Oct 16, 2019
FluentWait could potentially never complete when the condition
passed to it made no progress (either because it fall into an
infinite loop or waiting for a resource or response over
network).

Fixes SeleniumHQ#7494
utamas added a commit to utamas/selenium that referenced this issue Oct 16, 2019
Hanged is a dodgy expression.

Fixes SeleniumHQ#7494
@lock
Copy link

lock bot commented Apr 15, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Apr 15, 2020
@barancev
Copy link
Member

Sorry to say this, but we decided to return back to the legacy (blocking) implementation after clients complains. It appears that many people use suboptimal approach to manage WebDriver instances using TreadLocal variables. And running conditions in a separate thread makes them lost their driver. So we decided to revert this change in favour of backward compatibility.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants