Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:18:40+00:00 2026-06-05T19:18:40+00:00

When using implicit waits, as advised here , I still sometimes want to assert

  • 0

When using implicit waits, as advised here, I still sometimes want to assert the immediate invisibility or non-existence of elements.

In other words, I know some elements should be hidden, and want my tests make that assertion fast, without spending several seconds because of the (otherwise useful) implicit wait.

One thing I tried was a helper method like this:

// NB: doesn't seem to do what I want
private boolean isElementHiddenNow(String id) {
    WebDriverWait zeroWait = new WebDriverWait(driver, 0);
    ExpectedCondition<Boolean> c = invisibilityOfElementLocated(By.id(id));
    try {
        zeroWait.until(c);
        return true;
    } catch (TimeoutException e) {
        return false;
    }
}

But in the above code, the call to until() only returns after the implicit wait time has passed, i.e., it doesn’t do what I wanted.

This is the only way I’ve found so far that works:

@Test
public void checkThatSomethingIsNotVisible()  {
    turnOffImplicitWaits();
    // ... the actual test
    turnOnImplicitWaits();
}

… where e.g. turnOffImplicitWaits() is a helper in common Selenium superclass:

protected void turnOffImplicitWaits() {
    driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
}

But that is not very elegant, I think. Is there any cleaner way to bypass the implicit wait occasionally?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:18:41+00:00Added an answer on June 5, 2026 at 7:18 pm

    Given that Selenium doesn’t seem to offer what I want directly (based on what Mike Kwan and Slanec said), this simple helper method is what I went with for now:

    protected boolean isElementHiddenNow(String id) {
        turnOffImplicitWaits();
        boolean result = ExpectedConditions.invisibilityOfElementLocated(By.id(id)).apply(driver);
        turnOnImplicitWaits();
        return result;
    }
    
    private void turnOffImplicitWaits() {
        driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
    }
    
    private void turnOnImplicitWaits() {
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    }
    

    If the element is hidden or not present at all, the method returns true; if it is visible, returns false. Either way, the check is done instantly.

    Using the above is at least much cleaner than littering the test cases themselves with calls to turnOffImplicitWaits() and turnOnImplicitWaits().

    See also these answers for fined-tuned versions of the same approach:

    • Using try-finally to turn implicit waits back on
    • Using By locator as the parameter
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Full implementation is here https://gist.github.com/1306491 I'm using struct with implicit casting to implicitly convert
I want to use reflection and do either an implicit or explicit coversion using
I am working on using Matplotlib to produce plots of implicit equations (eg. y^x=x^y).
Using Yii, I want to delete all the rows that are not from today.
I am using Implicit Data Templates which are applied to the items of an
I'm having trouble getting my dll to work when using explicit linking. Using implicit
I often find myself wanting to just print (using the implicit toString() of each
What are the pros/cons of using implicit interfaces (Cases 2 and 3; templates) vs
Is there anything wrong with using an implicit operator like the following: //linqpad c#
(Using django as an example; the ForeignKey is implicit in the example) >>> from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.