0
votes

I'm currently using the chrome driver with C# webdriver. one of the problems i'm facing is waiting for "exist" or "visible" is not working in my case because the modal window takes some time to go away. and i'm getting this error:

System.InvalidOperationException: unknown error: Element is not clickable at point (x,x). Other element would receive the click:

reason being that the modal backdrop is still present for a few seconds after I click OK/Cancel, but the element behind the backdrop is visible and clickable to selenium.

so how do i "wait" until the modal backdrop is completely gone before attempting to click something behind it? this is not a native javascript modal. it's a fancy third party modal that slides in and out of view with a transparent "cover" that prevents clicking on anything else when it's open.

1
have you tried Thread.Sleep(...) ? - Nick Kahn
post your code maybe it will help to answer you better - Nick Kahn
Selenium already has a built-in mechanic to force the browser to wait. Check the documentation for it here. - Brian
Well what "third party tool"? Is it a jQuery plugin? Have you checked the dialog's .Displayed property? - Arran
@AbuHamzah I actually read somewhere here that using Thread.Sleep is bad practice. I'm wondering why there is not a simple Pause() in webdriver for X seconds? - ijjo

1 Answers

4
votes

You could user the ExpectedConditions API, such as:

var wait = new WebDriverWait(driver, TimeSpan.FromMinutes(1));
var element = wait.Until(ExpectedConditions.ElementIsClickable(By.Id("elementId")));

This will try during 1 minute until the element is clickable and is it does not happen it will throw an exception.