dotnet-client icon indicating copy to clipboard operation
dotnet-client copied to clipboard

Explicit wait not ignoring exceptions

Open kfertitta opened this issue 3 years ago • 3 comments

I feel like I'm missing something fundamental, as the explicit wait feature doesn't seem to actually ignore exceptions no matter what I try. I also never see my condition executed more than once, even if the timeout is 60 seconds and the polling interval is 1 second. Does this feature work at all or am I misusing it?

            var wait = new WebDriverWait(Session, TimeSpan.FromSeconds(120));

            wait.IgnoreExceptionTypes(typeof(Exception));

            wait.Until(s =>
            {
                var tree = Session.FindElementByXPath("//Tree[@Name='Solution Explorer']");

                return tree.FindElementByXPath("//TreeItem[@Name='Acme4301']");
            });

kfertitta avatar Mar 13 '21 01:03 kfertitta

Hi @akinsolb ,

Any work at all on this issue? It's been quite a while and never received any response at all.

Thanks very much in advance.

kfertitta avatar Oct 20 '21 13:10 kfertitta

@kfertitta Will look into it this week

laolubenson avatar Oct 25 '21 12:10 laolubenson

@akinsolb something I can give a hand with here?

Dor-bl avatar Sep 01 '22 19:09 Dor-bl

Duplicate of https://github.com/appium/appium-dotnet-driver/issues/225

Dor-bl avatar Nov 07 '22 14:11 Dor-bl

@Dor-bl Are you sure this is a duplicate of #225 ? The behavior described there is not what I'm seeing and the only thing I saw there as a resolution was use of ignored exceptions, which I'm already doing.

kfertitta avatar Nov 07 '22 14:11 kfertitta

I reopened. @akinsolb said he will take a look

Dor-bl avatar Nov 07 '22 14:11 Dor-bl

@kfertitta after reviewing your issue with selenium collaborator, this is the expected behavior. In his words : It's absolutely expected behavior. The WebDriverTimeoutException can't be ignored by the WebDriverWait. The condition not bing met before the timeout expires is an exceptional condition, as you're explicitly waiting for the condition to be truthy (return true or non-null), and thus, when the timeout expires without the condition being met, throwing an exception is the proper behavior. So you should basically wrap your code with try-catch and handle it the way you want.

Dor-bl avatar Nov 13 '22 16:11 Dor-bl

@Dor-bl Thank you very much for the follow-up. I see then from your comments that it's just that particular exception that can't be ignored.

kfertitta avatar Nov 13 '22 16:11 kfertitta

Correct, I'll keep this issue open for now . I'll add a test integration for this aspect in the coming days.

Dor-bl avatar Nov 13 '22 16:11 Dor-bl

Pushed a PR for adding related coverage: https://github.com/appium/dotnet-client/pull/555

Dor-bl avatar Nov 15 '22 07:11 Dor-bl