Selenium-client - get matching elements and their attributes

hi all

I’m using selenium-client with selenium rspec. I’m trying to build a
helper method that will, given this html on the page…

<div id="flashes">
    <p id="flash_notice" class="messages notice">good things</p>
    <p id="flash_errors" class="messages errors">bad things</p>
    <p id="flash_help" class="messages help">helpful things</p>

…generate this hash:

{:notice => “good things”, :errors => “bad things”, :help => “helpful

Ideally i’d like to keep it flexible so i don’t have to tell it to
specifically look for notice, errors and help, but just pull out
whatever’s there in the flashes div.

I’ve been trying to do this using xpath selectors but am struggling
because, for example,

@browser.get_attribute("//div[@id=‘flashes’]/[email protected]")

just returns the first p tag’s id, rather than an array of ids for
example. I get the feeling that i’m missing something fundamental.

grateful for any advice - max

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