0

When I run my test, I receive an error because an element obscures the element I want to click.

How do I create a wait that will be executed only IF this class is detected, wait it to disappear and finally continue the test?

I tried to make a wait but when then the driver will search this BLOCK-UI, it throws the error "element was not found". How do I create this wait ONLY WHEN this element is displayed?

[Test]
        public void TC_1848() // Verify Manage V-Tenant USERS Groups Office365 Groups TestCase
        {
            var vtenants = new ObjectRepository.VTenants(driver);

            ActionModules.SearchVTenant(driver);
            Thread.Sleep(1500);
            vtenants.VT_Usersbtn.Click();
            vtenants.VT_UserGroupsbtn.Click();
ERROR:  Element <a class="button button-fleft searchButton" href="#"> is not clickable at point (577.6166763305664,225.06666564941406) because another element <div class="blockUI blockOverlay"> obscures it
0

You have two options:

1 - Wait for the invisibility of an element

wait.Until(ExpectedConditions.InvisibilityOfElementLocated(element));

2 - Wait for the element to be clickable

wait.Until(ExpectedConditions.ElementToBeClickable (element));

You can find other ExpectedConditions here.

Note: wait is simply a WebDriverWait object

var wait = new WebDriverWait(browser.Driver, new TimeSpan(0, 0, seconds));
0

Let`s debug that situation to know its root cause of this Exception. IMO before emitting scrollTo or make any waits. Looks like the algorithm of selenium click is:

  1. Calculate element position
  2. ScrollTo this position (so you don't need to issue it yourself)
  3. Click to this position (exception comes from last assertion which checks what element stands on this position just before actual click event sending)

My advices are:

  1. Check if element is inside your viewport.
  2. Check if element is covered by any other (like sticky menus), hide them if there are any, or scroll manually before click without relying on builtin scrollTo.

Also some of these group discussion might helps you:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.