How to get CSS Style of section in Siteprism Page object model using Cucumber/Capybara

1.1k Views Asked by At

How to get CSS Style of section in Siteprism Page object model using Cucumber/Capybara. For an element, I use the below code to get CSS

@app.page_name.element_name.css('height')

For sections, When I try to use same as above like

@app.page_name.section_name.css('height')

I am getting error as

undefined method `css' for #section_name_Section:0x3635b08> (NoMethodError)

Is there anyway to get css of section directly instead of creating one more element for the same section and using it?

or

Is there any way to convert section into element in step definitions?

2

There are 2 best solutions below

0
On BEST ANSWER

Instead of:

@app.page_name.section_name.css('height')

...try:

@app.page_name.section_name.root_element.css('height')
0
On

If you want to get the root full css selector (Class only), use ['class'] as an attribute which will then be returned.

So @app.page_name.selector['class']