poltergeist

create a post request using poltergeist and capybara

杀马特。学长 韩版系。学妹 提交于 2020-02-24 12:01:32
问题 I'm transitioning from Capybara backed by the default Rack driver to Capybara backed by Poltergeist. For frustrating reasons, I need to manipulate session data before loading a page. But I couldn't figure out how to manipulate the session directly with the Rack driver, so I Capybara.current_session.driver.submit :post, "/current_search", {:session => :data } Unfortunately, the Poltergeist driver object has no submit method, as the Rack driver had. There are three possibilities: How do I

How to get poltergeist/PhantomJS to delay returning the page to Capybara until AJAX is loaded?

て烟熏妆下的殇ゞ 提交于 2020-01-04 15:27:54
问题 How do I keep PhantomJS from returning the page to Capybara for several seconds to allow AJAX to finish loading? The HTML body I am getting back is: <!--div class='loading'>PLEASE WAIT WHILE PAGE LOADS</div--> Which is telling me that PhantomJS returned the page before the page finished loading its AJAX assets. Is there any way I can slow this down? I've tried using the rasterize.js solution but it looks as though any script I add to poltergeist's "phantomjs_options" hash is overlooked. 回答1:

Rspec+Capybara optionally change JS driver

梦想的初衷 提交于 2020-01-03 13:55:09
问题 I use poltergeist/phantomjs for CI, but I want to be able to optionally change the JS driver to selenium to watch my test runs locally. Ideally I'd like to have a command line flag for this- default poltergeist, but be able to run rspec --driver=selenium (or something similar) Any ideas? 回答1: Never ended up finding an answer for this, so here's the hacky solution I came up with: The only thing I found that I could reliably change was the tagging system. So I call using -t visual tag and then

Why rspec doesn't wait completion of previous command?

青春壹個敷衍的年華 提交于 2019-12-25 03:44:26
问题 My rails-app contain rspec-tests using Capybara poltergeist (which uses phantomjs). Frontend is Backbone.js. Some tests are sometimes passed, sometimes not. Debugging shows that the right content is not loaded at the time of inspection. If i add an delay, e.c. sleep (inspection_time = 1), then the test passes. describe 'Direct visit page / # / desk / page / [ID]' do before {sign_in user} it 'should contain page title' do visit "/#/desk/pages/#{page.id}" #sleep (inspection_time = 1) expect

Difference between click_on and click_link?

纵饮孤独 提交于 2019-12-24 15:01:17
问题 I am writing request specs and I am using poltergeist-1.0.2 and capybara-1.1.2. I have the following code: login_as @user, 'Test1234!' click_on 'Virtual Terminal' the login has flash message that shows to the user that he is successfully logged in. When I am using click_link, the spec fails because Capybara can't find element 'Virtual Terminal' but when I am using click_on everything passes. 'Virtual Terminal' is not a button, it is a link. What is the difference between click_on and click

Why does visiting my root path require warmup time to make my test data available?

两盒软妹~` 提交于 2019-12-24 02:06:14
问题 I am in the process of switching from capybara-webkit to poltergeist/phantomjs. I'm experiencing a timing problem and I've determined which line of code needs warmup time, but I can't determine why this is or how to solve it. I have a 225 line spec file with a couple dozen tests. On any given test run, 1 or 2 of them will consistently fail. It can be any of them, it's not consistent. This before block applies to all the tests. I've annotated the code to explain the situation. before do # -->

Capybara + Poltergeist with Database-cleaner not finding FactoryGirl records

懵懂的女人 提交于 2019-12-23 17:24:51
问题 I'm writing integration tests and creating records with FactoryGirl . My controllers are throwing RecordNotFound when the test has js: true (with Poltergeist) even though they are found in a non-js test (without Poltergeist). I do have use_transactional_fixtures set to false and DatabaseCleaner.strategy set to :truncation , which seemingly covers every existing SO question on this issue. I tried substituting Selenium (with Firefox) for Poltergeist but I get the same result. ETA I started a

Capture video with Poltergeist, PhantomJS and Capybara

淺唱寂寞╮ 提交于 2019-12-23 09:52:50
问题 Is it possible to capture video with PhantomJS in combination with the gems Poltergeist, Capybara and Cucumber? I have used the Headless gem previously, which put a video in a specific folder in case a scenario failed. If all went well, no video was stored. Headless uses Xvfb and ffmpeg. Can ffmpeg also be used to provide the same functionality as shown here: https://github.com/leonid-shevtsov/headless/blob/master/lib/headless/video/video_recorder.rb I basically need the same functionality,

Poltergeist throws JS errors when js_errors: false

被刻印的时光 ゝ 提交于 2019-12-20 18:07:27
问题 I have a large test suite that is using poltergeist and capybara. I keep getting the following error: One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details). I am pretty sure I have set js_errors: false but I am still getting the errors. I realize that the optimal solution is to fix the JS but I am inheriting legacy code and fixing

Downloading file to specific folder using Capybara and Poltergeist driver

时间秒杀一切 提交于 2019-12-17 23:47:10
问题 I am writing my acceptance tests using Capybara and Poltergeist driver.I need to validate the content of the CSV file downloaded. I tried various ways of rendering the content on the page itself instead of downloading it. Also tried changing the mime types, but it is not working. Finally I want to settle down with the option of downloading the file in a specific folder and then read the CSV file using core ruby libraries. In order to achieve this,when poltergeist driver clicks on download