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

  • SEARCH
  • Home
  • 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 5848021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:48:05+00:00 2026-05-22T12:48:05+00:00

Every now and then my selenium tests randomly fail with an element X not

  • 0

Every now and then my selenium tests randomly fail with an “element X not found” error message. I do a simple select by ID, eg.

click('sideBar_queryButton')

When I use the dom inspector, the element is there, so I wonder why selenium doesn’t find it sometimes. When I run the same test again, it works or it breaks again, there seems to be no reliable way of reproducing it. Even tests which are there for ages seem to randomly break and then magically work again. Inserting a few sleep statements sometimes helps but not reliably. So I wonder if I’m using it incorrectly. Has anyone else had these problems with selenium and if so, how did you fix them?

  • 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-05-22T12:48:05+00:00Added an answer on May 22, 2026 at 12:48 pm

    Edit: I found it to be much more reliable to put some test markers in my pages and wait for them to appear. If you use asynchronous operations which might create race conditions in your tests, inserting a test marker into your html after you finish the operation worked pretty well for me. E.g.

    $('<div>').addClass("testMarker").append("OpXYZFinished").appendTo($('#content'));
    

    That way, you can do a simple “waitForTextPresent” to see if things worked out and its much more reliable than guessing the browser’s loading state. The testmarker class needs to be formatted in a way that it is not visible to the user (e.g. font color == background color).

    Thanks for all your comments. After some deeper digging on the net and
    in our tests I finally found combining these statements instead of a
    simple waitForPageToLoad to be the cure for our issues:

    waitForPageToLoad('')
    // wait until all ajax activity has ceased. That check's jQuery's $.active
    waitForCondition('selenium.browserbot.getUserWindow().$.active == 0', 5000)
    // wait a second for all JS to properly initialize
    pause(1000)
    

    There is still a pause in there which is somewhat ugly, but it does
    the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Every now and then I get an error when I set up states in
I have an application where every now and then I'm getting a strange error.
Every now and then I start getting this error in the debugger constantly. Sometimes
Every now and then I sometime get the following error A component named dlgPrinterSettings
I have a Windows application, it crashes every now and then and not reroducibly.
Every now and then, I bump into syntax that I've seen before, but never
This problem crops up every now and then at work. Our build machine can
I'm running an open source project and every now and then Chinese users report
I use Firebug and the Mozilla JS console heavily, but every now and then
I'm looking for an overview of algorithms, you need every now and then. If

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.