Sunday, October 25, 2009

Workaround for Webrat's have_xpath()

I have the following xpath:

//td[normalize-space(text())='Peter']/parent::tr//label[normalize-space(text())="Present"]/@for

It is valid, yet webrat's have_xpath() kept complaining that it cannot find it. As a workaround, i did something like this in my cucumber:
1
2
hdoc = Nokogiri::HTML(response.body)
(field_id = hdoc.xpath(the_above_rejected_xpath)).first.should_not be_nil

That's all.

No comments:

Post a Comment

Labels