Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to expand a dynamic section of the UI without much success. It works like a charm in the console (using the rubyshell instance) but when I execute this in a batch on TestWise I get this error:

undefined method `click' for nil:NilClass

Could you please have a look and maybe through some ideas?


<div id="ID1">
   <div id="ID2" class="CLASS1" xmlns="">
    <div class="CLASS2" onclick="some javascript goes here">
        <span class="CLASS3">Some text goes here</span>
    <div id="ID3" class="CLASS4"></div>

And the Watir code:

@browser.div(:id, "ID1").div(:id, ID2).span(:class, "CLASS3").click


share|improve this question

Well, the error message says that span(:class, "CLASS3") returns nil.

If the code works in IRB but not when you run the script, it is usually timing problem. Maybe the element is not at the page when you try to access it.

By the way, div(:id, ID2) should be div(:id, "ID2") (please notice the quotes), otherwise it should raise NameError: uninitialized constant ID2 (assuming that you did not define constant ID2 any you want to access <div id="ID2">.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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