Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to modify style using Cucumber + Capybara?

Tags:

css

ruby

capybara

So I have the scenario where I want to demonstrate to the business how Cucumber can be of benefit. It's easy to setup a demo and run but, without the proper visuals, the business won't really see the benefit... question is: is it possible to add a CSS class whilst the feature is being executed?

Something like this:

anchor = page.find_link(link);
anchor[:style].value = 'outline:yellow solid thick';
sleep 1;
click_link(link);

What I'm not sure is the second line. How can I achieve an outline style on an element that is about to be clicked?

I couldn't find anything similar on the actual Cucumber spec. Any help would be appreciated.

like image 608
Tarcio Saraiva Avatar asked Feb 09 '12 03:02

Tarcio Saraiva


1 Answers

Ok I found a solution: execute a script to modify the CSS.

page.execute_script("$('selector').css('property','value')");

Works quite well :-)

like image 123
Tarcio Saraiva Avatar answered Nov 15 '22 18:11

Tarcio Saraiva