Here’s what the HTML looks like:
<dt> Static text. </dt>
<dd>
<a onclick="bunch of ajax stuff", href="#">
Dynamic Text!
</a>
</dd>
I tried to use the <dt> to locate the <dd> element with the code $browser.dd(:after? => $browser.dt(:text => /Static text./)).text, but that gives an undefined method 'join' for #<String:0xblah> error. The dd doesn’t have an id or anything to locate it with. I was able to get the .text from it by doing a regex search for part of it in irb, but that won’t work too well long-term since it’s a dynamic value.
I assume your HTML looks like the following, plusing your above comment. Is that correct?
<dl> <dt> Static text. </dt> <dd> <a onclick="bunch of ajax stuff", href="#"> Dynamic Text! </a> </dd> <dd id='foo'> bar </dd> </dl>If so, you might be able to get the first DD text like this.
or
If you can grab the second DD easily, the following is worth to try, I think
or
or.. If the target DD is always the next sibling of DT, try element_by_xpath. It’s my last resort 🙂