0

Is there a way to get the css selector for a page object you defined in SitePrism? For instance if I have

class myPageObject < SitePrism::Page
  ...
  element :my_element, '.my-element-class'
  ...
end

How could I use the selector in a test to get .my-element-class?

Ben Hare
  • 4,365
  • 5
  • 27
  • 44

2 Answers2

1

No - SitePrism doesn't store the parameters passed to element in any accessible way

Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78
  • Aright thanks for helping, figured I'd ask as I couldn't find any information on it while I was looking. – Ben Hare Dec 05 '16 at 22:17
0

Old post but adding for info

A specific element on a page will only have 1 xpath (Or possible a subset of these), but it is very definitely finite. This is because of the way xpath is inherently structured. It represents the DOM.

CSS Selectors can be defined in a multitude of ways, and as such it can be considered than a single element could have infinite css selectors.

If you want to find out the specific class property of an element, that is possible by doing my_page.my_element['class'] - However this will return a space delimited string of just the class properties of the current element.

Luke Hill
  • 460
  • 2
  • 10