I'm in the process of developing a web application that dynamically changes its CSS styles based on user input. Everything is working smoothly, but I'm facing an issue with my automated tests not confirming whether the CSS updates are actually taking place.
Essentially, I just need to validate if the content within a <style>
tag in the document's <head>
has been modified to a specific value. For my testing, I am utilizing capybara (with the selenium driver) and have written the following code:
styles = page.all('style')
styles.length.should == 1
styles[0].text.should == style
Everything seems to be functioning correctly until the last line, where it fails because styles[0].text
always returns an empty string. I've attempted using .value
, which consistently returns nil
. Despite this, I am fairly certain that the CSS changes are being applied, as I can visually see them in the Firefox window that the tests are executing in.
So, my question is - is there a method to access the contents of the <style>
tag using capybara?