3

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.

1 Answer 1

2

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">.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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