Nokogiri selector help

hiya,

i want the selector that would return a

of a table if any td
contains some text, so i can use it in click_link_within

e.g. When I click the “show” link within the row containing
[email protected]

When /^I click the “(.+)” link within the row containing “(.+)”$/ do |
link, text|
selector = ??
click_link_within selector, link
end


and lets say the response contains

......
show foo bar [email protected] baz
...

On Sat, Jan 24, 2009 at 12:05 AM, Jonathan L.
[email protected] wrote:

text|
selector = ??
click_link_within selector, link
end

You can use an XPath selector to find the parent. Try:

selector = “//table//tr//td[contains(.,‘[email protected]’)]//…”

 <tr>


Zach D.
http://www.continuousthinking.com
http://www.mutuallyhuman.com

On Jan 25, 2009, at 11:58 AM, Zach D. wrote:

selector = “//table//tr//td[contains(.,‘[email protected]’)]//…”
hi Zach,

that works as a selector when I do
doc = Nokogiri::HTML.parse( response.body )
doc.xpath(selector)
returns the correct dom elements

but when used with click_link_within I get the error

Nokogiri::CSS::SyntaxError Exception: unexpected ‘//’ after ‘’

On Fri, Jan 30, 2009 at 9:45 PM, Jonathan L.
[email protected] wrote:

some text, so i can use it in click_link_within
end
returns the correct dom elements

but when used with click_link_within I get the error

Nokogiri::CSS::SyntaxError Exception: unexpected ‘//’ after ‘’

Sorry for the late reply, but this is a bug in webrat not a nokogiri
issue. I’ve created a ticket for it at lighthouse:

http://webrat.lighthouseapp.com/projects/10503-webrat/tickets/153-within-should-support-xpath


Zach D.
http://www.continuousthinking.com
http://www.mutuallyhuman.com

Sorry for the late reply, but this is a bug in webrat not a nokogiri
issue. I’ve created a ticket for it at lighthouse:

http://webrat.lighthouseapp.com/projects/10503-webrat/tickets/153-within-should-support-xpath

I wrote an ugly duckpunch that fixes the error for now. I have submitted
it as a comment on the ticket

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs