By using site-prism gem for integration testing, can I find page elements by referring to id or title or link or xpath or are they searchable only through css
Asked
Active
Viewed 4,485 times
1 Answers
5
UPDATE: It is possible, as of SitePrism 2.1 to use XPath expressions to find elements and sections, as well as CSS selectors.
====
You can only use CSS selectors, but using CSS you can still find elements by id, class, name, title, etc.
If you want to find an element by id:
#the_id
If you want to find an element by class:
.the_class
If you want to find an element by title:
div[title='the_title']
So, not exactly what you want, but you can get close.
Regarding XPath, see here: Does site_prism allow using other selectors than CSS?
Update
To find a link whose name property is 'bob':
a[name='bob']
To find a button whose id is 'fred':
button#fred

Community
- 1
- 1

Nat Ritmeyer
- 5,634
- 8
- 45
- 58
-
Thank You. What about finding a link or a button and performing actions (like click) on them? – bugsberry Aug 31 '12 at 20:25
-
1Finding any element type (link/button/etc) using a CSS selector is trivial. CSS selectors are quite easy to learn. Here's a great resource: http://www.w3.org/TR/CSS2/selector.html – Nat Ritmeyer Aug 31 '12 at 20:37
-
Hi Nat. One more question. How to define images on pages? Like when i have something like this.
– bugsberry Mar 06 '13 at 21:57
-
I just did. Sorry it wasn't clear to me what that does and how it's useful. – bugsberry Mar 12 '13 at 20:46
-
1Can i select a link by text using site-prism? – bugsberry Jun 07 '13 at 23:40