Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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:

NoMethodError:
undefined method `click' for nil:NilClass

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

HTML

<div id="ID1">
   <div id="ID2" class="CLASS1" xmlns="http://www.w3.org/1999/xhtml">
    <div class="CLASS2" onclick="some javascript goes here">
        <span class="CLASS3">Some text goes here</span>
    <div id="ID3" class="CLASS4"></div>
</div>

And the Watir code:

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

Thanks.

share|improve this question
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.