poltergeist

Using poltergeist with a proxy?

一世执手 提交于 2019-12-04 01:43:01
问题 I'm using PhantomJS and poltergeist to emulate a browser, however I'm not sure how to specify a proxy to use in the code: require 'capybara' require 'capybara/dsl' require 'capybara/poltergeist' task :experiment => :environment do Capybara.run_server = false Capybara.current_driver = :poltergeist Capybara.app_host = "http://something.com" include Capybara::DSL # set_proxy('12.13.14.15', '4521') visit('posts') page.include?('foo') end Also, for some reason, i get undefined method page when

How to configure Poltergeist or PhantomJS to not follow redirects?

吃可爱长大的小学妹 提交于 2019-12-04 01:40:58
问题 I have some tests that require the JS driver to not follow redirects. Is it possible to configure Poltergeist to do this? I noticed that it is possible to pass commands to PhantomJS using the Command Line Interface, so perhaps that is another way of doing this? 回答1: I'm not familiar with Poltergeist, so I'm only going to answer about PhantomJS. All you need for this are the two event handlers page.onResourceRequested and page.onResourceReceived. An HTTP redirect produces both a HTTP request

Why is Capybara discarding my session after one event?

主宰稳场 提交于 2019-12-03 23:27:10
问题 Testing a rails application which has before_filter :authenticate_user! for most controllers, I cannot get Capybara to preserve a session. I have Capybara configured using PhantomJS with poltergeist. I use the following helper: require 'spec_helper' include Warden::Test::Helpers module FeatureHelpers def login(user = FactoryGirl.create(:default_user)) login_as user, scope: :user user end end I have the following spec file: require 'spec_helper' include Warden::Test::Helpers feature 'Leads

How to set text into Summernote textarea with Capybara + Poltergeist

半世苍凉 提交于 2019-12-01 18:41:04
I have a textarea which is using Summernote and I set onChange event to it. I want to write test with RSpec + Capybara + Poltergeist to confirm the onChange event is working. As far as I checked, the textarea displayed in browser is actually div tag with 'note-editable' css class. How can I set text to it and fire onChange event? I wrote a code like this, but got an error Capybara::ElementNotFound: Unable to find field "Some label" : visit edit_foo_path fill_in 'Some label', with: 'Foo bar' EDIT I created a sample app for this issue: https://github.com/JunichiIto/summernote-rspec-sandbox Raw

How to return a value when using execute_script in capybara?

一个人想着一个人 提交于 2019-12-01 14:56:19
I have a really simple line in a test that calls execute script like this: puts page.execute_script("return somefunction();").to_i.inspect And in javascript I have a function like this: function somefunction(){ console.log("test"); return 999; } The 'test' from the console log is getting logged out so it is running however... Looking at the logs when running the test, the execute_script returns 0 not 999, so in rspec I can't get at the return value from the function, how do I make page.execute_script return that value from that function? The Poltergeist driver is designed to return nil for

How to return a value when using execute_script in capybara?

☆樱花仙子☆ 提交于 2019-12-01 13:41:32
问题 I have a really simple line in a test that calls execute script like this: puts page.execute_script("return somefunction();").to_i.inspect And in javascript I have a function like this: function somefunction(){ console.log("test"); return 999; } The 'test' from the console log is getting logged out so it is running however... Looking at the logs when running the test, the execute_script returns 0 not 999, so in rspec I can't get at the return value from the function, how do I make page

How to configure Poltergeist or PhantomJS to not follow redirects?

99封情书 提交于 2019-12-01 08:11:51
I have some tests that require the JS driver to not follow redirects. Is it possible to configure Poltergeist to do this? I noticed that it is possible to pass commands to PhantomJS using the Command Line Interface , so perhaps that is another way of doing this? I'm not familiar with Poltergeist, so I'm only going to answer about PhantomJS. All you need for this are the two event handlers page.onResourceRequested and page.onResourceReceived . An HTTP redirect produces both a HTTP request and HTTP response on so the handlers are called when the redirect response is received. You can then add

Why is Capybara discarding my session after one event?

时间秒杀一切 提交于 2019-12-01 02:19:25
Testing a rails application which has before_filter :authenticate_user! for most controllers, I cannot get Capybara to preserve a session. I have Capybara configured using PhantomJS with poltergeist. I use the following helper: require 'spec_helper' include Warden::Test::Helpers module FeatureHelpers def login(user = FactoryGirl.create(:default_user)) login_as user, scope: :user user end end I have the following spec file: require 'spec_helper' include Warden::Test::Helpers feature 'Leads Data Tasks View' do before(:each) do @user = login end after{ Warden.test_reset! } context "clicking a

Opening a new tab in Capybara / Poltergeist

柔情痞子 提交于 2019-12-01 01:57:38
问题 I'm trying to open a link by clicking on it using capybara/poltergeist which opens up in a new tab. I can't seem to get it working. @session.find(<link>).click just seems to stay on the same page, as does click_link "<link>" @session.driver.window_handles Only seems to give me 1 window whatever I'm doing. How do I get that link to open in a new tab? Seems to be a fair amount of confusion as to what works or doesn't a la (With Capybara, how do I switch to the new window for links with "_blank"

How do poltergeist/PhantomJS and capybara-webkit differ?

蓝咒 提交于 2019-11-29 20:50:39
What are the differences between PhantomJS and capybara-webkit? What are the advantages of capybara-webkit over PhantomJS? Which of the two is the most efficient tool? Others ... poltergeist is the capybara driver for PhantomJS, a headless browser which is built on WebKit. capybara-webkit is a capybara driver which uses WebKit directly. poltergeist/PhantomJS has some big advantages over capybara-webkit: In my experience poltergeist/PhantomJS always times out when it should, whereas capybara-webkit sometimes hangs. Its error messages are much clearer. For example, it will actually tell you if