Random timeouts and elements that can't be found (Rails + selenium-webdriver)

466 views
Skip to first unread message

Clemens Kofler

unread,
Dec 30, 2010, 4:53:20 AM12/30/10
to Selenium Users
Hi,

I'm having issues with selenium webdriver and Rails. I get random
timeouts (sometimes it works, other times it doesn't) and selenium
randomly doesn't find elements I can clearly see (again, sometimes it
works and sometimes it doesn't).

The flow isn't "special": A user logs in and then uses search fields.
The only "special" thing about the search fields is that I have 3
dependent filters (select fields) where the first, when changed,
(re-)populates the other two via AJAX (the surrounding div gets
replaced with a new one). Most timeouts seem to occur when searching
whereas elements not being found usually happens when logging in (it
often can't find the login button although it's clearly visible in the
browser window).

Setup:

Gems included by the bundle:
* aaronh-chronic (0.3.9)
* abstract (1.0.0)
* actionmailer (3.0.3)
* actionpack (3.0.3)
* activemodel (3.0.3)
* activerecord (3.0.3)
* activeresource (3.0.3)
* activesupport (3.0.3)
* acts-as-taggable-on (2.0.6)
* addressable (2.2.2)
* arel (2.0.6)
* awesome_nested_set (1.5.0 6c98d59)
* bcrypt-ruby (2.1.3)
* bitly (0.5.5)
* builder (2.1.2)
* bundler (1.0.0)
* capistrano (2.5.19)
* capistrano-ext (1.2.1)
* capybara (0.3.9)
* cgi_multipart_eof_fix (2.5.0)
* childprocess (0.1.6)
* columnize (0.3.2)
* configuration (1.2.0)
* crack (0.1.8)
* cucumber (0.10.0)
* cucumber-rails (0.3.2)
* culerity (0.2.13)
* curb (0.7.9)
* daemons (1.1.0)
* database_cleaner (0.6.0)
* devise (1.2.rc af12952)
* diff-lcs (1.1.2)
* erubis (2.6.6)
* exceptional (2.0.32)
* faker (0.3.1)
* fakeweb (1.3.0)
* faraday (0.5.3)
* fastercsv (1.5.3)
* fastimage (1.2.8)
* fastthread (1.0.7)
* ffi (0.6.3)
* gem_plugin (0.2.3)
* gherkin (2.3.3)
* globalize3 (0.0.10)
* handsoap (1.1.7)
* highline (1.6.1)
* hpricot (0.8.3)
* httparty (0.6.1)
* i18n (0.5.0)
* jrails (0.6.0)
* json (1.4.6)
* json_pure (1.4.6)
* launchy (0.3.7)
* linecache (0.43)
* macaddr (1.0.0)
* machinist (2.0.0.beta2)
* mail (2.2.13)
* mime-types (1.16)
* mongrel (1.1.5)
* multi_json (0.0.5)
* multipart-post (1.0.1)
* mysql2 (0.2.6)
* net-scp (1.0.4)
* net-sftp (2.0.5)
* net-ssh (2.0.23)
* net-ssh-gateway (1.0.1)
* newrelic_rpm (2.13.4)
* nokogiri (1.4.4)
* oa-core (0.1.6)
* oa-oauth (0.1.6)
* oauth (0.4.4)
* oauth2 (0.1.0)
* orm_adapter (0.0.3)
* paperclip (2.3.8 5eaadd2)
* polyglot (0.3.1)
* rack (1.2.1)
* rack-mount (0.6.13)
* rack-test (0.5.6)
* rails (3.0.3)
* railties (3.0.3)
* rake (0.8.7)
* rcov (0.9.9)
* redis (2.1.1)
* redis-namespace (0.8.0)
* request-log-analyzer (1.9.9 e00a164)
* resque (1.10.0)
* riddle (1.2.2)
* routing-filter (0.2.2 4a20bbd)
* rspec (2.3.0)
* rspec-core (2.3.1)
* rspec-expectations (2.3.0)
* rspec-mocks (2.3.0)
* rspec-rails (2.3.1)
* ruby-debug (0.10.4)
* ruby-debug-base (0.10.4)
* rubyzip (0.9.4)
* selenium-webdriver (0.1.2)
* sinatra (1.1.2)
* system_timer (1.0)
* term-ansicolor (1.0.5)
* thinking-sphinx (2.0.1)
* thor (0.14.6)
* tilt (1.2.1)
* treetop (1.4.9)
* tzinfo (0.3.23)
* uuid (2.3.1)
* vegas (0.1.8)
* warden (1.0.3)
* whenever (0.6.2)
* will_paginate (3.0.pre2)

Nothing worth mentioning in Cucumber's env.rb and I'm using the
standard Firefox driver (Firefox 3.6.13). I'm using Ruby 1.8.7p302 via
RVM on OS X 10.6.

If you need more info, let me know.

Does anyone have any hint where to start looking? I'm thankful for any
hint.

Thanks,
- Clemens

Jari Bakken

unread,
Dec 30, 2010, 9:31:26 AM12/30/10
to seleniu...@googlegroups.com
On Thu, Dec 30, 2010 at 10:53 AM, Clemens Kofler <cle...@railway.at> wrote:
> Hi,
>
> I'm having issues with selenium webdriver and Rails. I get random
> timeouts (sometimes it works, other times it doesn't) and selenium
> randomly doesn't find elements I can clearly see (again, sometimes it
> works and sometimes it doesn't).
>
>

Having the full error message + backtrace of these errors would be
helpful (especially for the timeouts).

If WebDriver doesn't find elements, it's usually a timing issue. Are
these failures related to elements being added/removed by JS? If so
you'll often need to explicitly wait for the elements to appear before
trying to interact with them. This isn't something you'd catch with
the naked eye. To diagnose the problem you see if adding a short
sleep() before the element lookups does help, and if it does, add a
more robust solution (polling the DOM).

Clemens Kofler

unread,
Dec 30, 2010, 1:51:11 PM12/30/10
to Selenium Users
Here's the backtrace for the element not being found:

Element not found in the cache
(Selenium::WebDriver::Error::ObsoleteElementError)
[remote server]
file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/resource/modules/utils.js:7081:in
`WebDriverError'
[remote server]
file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/resource/modules/utils.js:7198:in
`'
[remote server]
file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/components/driver-component.js
-> file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/components/firefoxDriver.js:540:in
`'
[remote server]
file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/components/driver-component.js
-> file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/components/firefoxDriver.js:644:in
`'
[remote server]
file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/resource/modules/atoms.js:277:in
`'
[remote server]
file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/components/nsCommandProcessor.js:299:in
`'
[remote server]
file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/components/nsCommandProcessor.js:313:in
`'
[remote server]
file://./tmp/webdriver-profile20101230-39205-byo0l7/extensions/fxdr...@googlecode.com/components/nsCommandProcessor.js:190:in
`'
./features/step_definitions/web_steps.rb:72
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:71:in `/^(?:|I )select
"([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/'
features/pixsetter/search.feature:30:in `And I select "<brand>" from
"brand_name"'

A timeout didn't happen this time.

On Dec 30, 3:31 pm, Jari Bakken <jari.bak...@gmail.com> wrote:

Jari Bakken

unread,
Dec 30, 2010, 5:38:20 PM12/30/10
to seleniu...@googlegroups.com
On Thu, Dec 30, 2010 at 7:51 PM, Clemens Kofler <cle...@railway.at> wrote:
> Here's the backtrace for the element not being found:
>
> Element not found in the cache
> (Selenium::WebDriver::Error::ObsoleteElementError)

Not being found in the cache is different from the element just not
being found. This means that WebDriver's element reference is outdated
- this could happen if e.g. the page was refreshed, or if the element
was removed and then re-added. In both instances the user should issue
a new find_element command and not rely on the old Element instance
being usable.

It also looks like you're using Capybara. There have been several
threads on their mailing list from people who are seeing
ObsoleteElementErrors, so it may very well be something in the
Capybara code base that is causing this to happen more frequently than
elsewhere (IIRC I've hinted at possible solutions to this in some of
those threads).

About the timeouts, do you know which command timed out? If your page
takes more than 60 seconds to load, then a call to Driver#get will
exceed the default Net::HTTP timeout (used internally for
communication with Firefox) and you'll see a timeout error. That
timeout can be tweaked - check the RubyBindings page on the Selenium
wiki.

Reply all
Reply to author
Forward
0 new messages