For weeks now, I've been dealing with an issue that seems to have no solution found online... like waiting for ajax, etc...
Check out the versions of gems:
- capybara (2.10.1, 2.7.1)
- selenium-webdriver (3.0.1, 3.0.0)
- rspec (3.5.0)
running ruby 2.2.5 ruby 2.2.5p319 (2016-04-26 revision 54774) [x64-mingw32]
In the env.rb file
Capybara.register_driver :selenium do | app |
browser = (ENV['browser'] || 'firefox').to_sym
Capybara::Driver::Selenium.new(app, :browser => browser.to_sym, :resynchronize => true)
Capybara.default_max_wait_time = 5
end
This is from my dynamicpage.feature file:
Given I visit page X
Then placeholder text appears
And the placeholder text is replaced by the content provided by the json service
Now, in the step.rb file:
When(/^I visit page X$/) do
visit('mysite.com/productx/')
end
When(/^placeholder text appears$/) do
expect(page).to have_css(".text-replacer-pending")
end
Then(/^the placeholder text is replaced by the content provided by the json service$/) do
expect(page).to have_css(".text-replacer-done")
end
The webpage that's causing me trouble isn't publicly accessible but on page load it contains:
1- <span class="text-replacer-pending">Placeholder Text</span>
After a call to an external service and data update, the span gets updated to:
2- <span class="text-replacer-done">Correct Data</span>
I'm facing an issue where Capybara + Selenium freezes the browser after visiting the page without letting the service update the content dynamically. I've tried various solutions like:
- Capybara.default_max_wait_time = 5
- Capybara::Driver::Selenium.new(app, :browser => browser.to_sym, :resynchronize => true)
- adding sleep 5 after the visit method
- waiting for ajax using different websites' solutions, etc...
- incorporating after hooks etc...
I am completely puzzled as to why the "visit" method can't wait or provide a simple fix for this commonly faced issue. While I know about Capybara methods that do and don't wait, the problem lies in:
- there's no transition from hidden to displayed content
- no user interaction involved, just updating content
Not sure if it's a Capybara, Selenium, or both issue. Any insight or solutions would be greatly appreciated, especially regarding which code goes where since I'm new to Ruby and Cucumber.
Mel