# Selenium-client - get matching elements and their attributes

**URL:** <https://www.ruby-forum.com/t/selenium-client-get-matching-elements-and-their-attributes/186020>\
**Category:** Rails\
**Created:** [March 30, 2010, 2:21pm UTC](https://www.ruby-forum.com/t/selenium-client-get-matching-elements-and-their-attributes/186020 "2010-03-30T14:21:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [March 30, 2010, 2:21pm UTC](https://www.ruby-forum.com/t/selenium-client-get-matching-elements-and-their-attributes/186020/1 "2010-03-30T14:21:35Z")

</div>

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>
</div>

```

…generate this hash:

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

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’]/p@id")

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
