jnicklas/capybara — Issue #636: Initialization JavaScript runs again on #save_and_open_page
Author: cvincent
Created: 2012-02-09 10:33:07+00:00
State: open

Consider the following page:

```html
Test

not clicked

```

And the following test:

```ruby
visit test_page
click_button 'Test'

page.driver.render('~/Desktop/test.png')
save_and_open_page
```

The rendered PNG will correctly display "clicked" in the test DIV, while the `save_and_open_page` will re-run the initialization JavaScript and overwrite the test DIV once again with "unclicked?".

The expected behavior:

1. Page loads. The DIV displays "not clicked".
2. The initialization script runs. The DIV displays "unclicked?".
3. The `click_button` call is made, and the DIV displays "clicked".

This appears to work for the `render` but not `save_and_open_page` because the latter causes the initialization script to be re-run.

Is there a workaround to prevent `save_and_open_page` from re-running included scripts which were already run in headless mode?