capybara

Capybara-webkit raises Capybara::Driver::Webkit::WebkitInvalidResponseError

醉酒当歌 提交于 2020-01-03 15:18:06
问题 I got following message from webkit driver in my rspec: Capybara::Driver::Webkit::WebkitInvalidResponseError: Unable to load URL: http://127.0.0.1:44923/posts Few days ago it worked. The problem is with save_page method. What could be wrong? 回答1: I've had similar error messages when my page was raising an error. You should check manually that this is not the case by starting a server in testing mode ( rails s -e test ) and accessing the page yourself. 回答2: Check if you don't have any other

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

How to resolve RSpec's deprecation warning about the new expect syntax?

六眼飞鱼酱① 提交于 2020-01-03 10:18:29
问题 When I run this RSpec example, it passes but I'm getting a deprecation warning. context "should have valid detail for signup" do it "should give error for invalid confirm password" do find("#usernamesignup").set("Any_name") find("#mobile_number").set("1234567890") find("#emailsignup").set("mymail@yopmail.com") find("#passwordsignup").set("12345678") find("#passwordsignup_confirm").set("") find(".signin").click sleep 2 page.should have_content "Confirm Password Does not Match" end end Here is

Select mixed mode content in Capybara

被刻印的时光 ゝ 提交于 2020-01-03 03:28:05
问题 I am trying to extract mixed mode content using Capybara. I did it using Nokogiri, but wonder why similar is not possible with Capybara. require 'nokogiri' doc = Nokogiri::HTML("<h1><em>Name</em>A Johnson </h1>") puts doc.at_xpath("//h1/text()").content It works, but when I try same XPath selector in Capybara it doesn't work. visit('http://stackoverflow.com') puts find(:xpath, "//h1/text()").text It raises error: [remote server] file:///tmp/webdriver-profile20120915-8089-kxrvho/extensions

How to reuse code in Capybara

爱⌒轻易说出口 提交于 2020-01-02 11:29:09
问题 I have a bunch of codes with repeating structures in a feature test in Rails. I would like to dry up my spec by reusing the structure. Any suggestions? An example is: feature "Search page" subject { page } it "should display results" # do something within "#A" do should have_content("James") end within "#B" do should have_content("October 2014") end # do something else # code with similar structure within "#A" do should have_content("Amy") end within "#B" do should have_content("May 2011")

How to adjust Capybara finders on a site using css-modules?

浪子不回头ぞ 提交于 2020-01-02 07:10:24
问题 In our automated tests, a typical line in our code might look something like: find('.edit-icon').click We're on our way to using css-modules in our project and I've been warned that class names may change dramatically. A pretty zany example is this site that uses emojis in its class names (when you inspect the page): css modules by Glenn Maddern How might I best prepare for a change this drastic? I imagine many of our specs breaking, but I am a little worried about being unable to write tests

How to set the ignore_ssl_errors option for Capybara Webkit in spec_helper.rb

◇◆丶佛笑我妖孽 提交于 2020-01-02 04:41:09
问题 In my spec_helper file I have: Capybara.javascript_driver = :webkit capybara_webkit now has a ignore_ssl_errors option that I want to use. How do I specify that in my spec_helper? 回答1: Here's how to register the :webkit driver with the :ignore_ssl_errors option. Capybara.register_driver :webkit do |app| Capybara::Driver::Webkit.new(app, :ignore_ssl_errors => true) end 回答2: As of writing (capybara-webkit 1.7.1), the configuration seems to have been simplified: Capybara::Webkit.configure do

capybara: fill in form field value with terminating enter key

橙三吉。 提交于 2020-01-02 03:31:07
问题 I'm testing a barcode reader input... it behaves like the keyboard but terminates each barcode with the enter key character. My javascript detects the enter key and responds (backbone.js application). How can I "fill in" a form field with a string that has a terminating enter key value? My test stack is cucumber/capybara/capybara-webkit. 回答1: Actually, it seems that you can just send a \n to capybara's native set method and achieve the same effect (in a more flexible, driver agnostic way). So

Capybara NoMethodError: undefined method `visit' for

放肆的年华 提交于 2020-01-01 18:28:26
问题 Thank for response. I getting error in application Git application with the error Failures: 1) Page pages page creation with invalid information should not create a page Failure/Error: before(:each) { visit new_admin_page_path } NoMethodError: undefined method `visit' for #<Page:0x00000005094bb0> # ./spec/requests/page_request_spec.rb:13:in `block (3 levels) in <top (required)>' 2) Page pages page creation with invalid information error messages Failure/Error: before(:each) { visit new_admin

How can I configure puma when running Capybara?

被刻印的时光 ゝ 提交于 2020-01-01 08:45:12
问题 I'd like to adjust the puma configuration when running Capybara tests. Changing settings in .env, .env.test (I use dotenv), or config/puma.rb has no effect. Where can I change the configuration? Rails 5.1, poltergeist 1.15.0, capybara 2.14.0, puma 2.8.2 回答1: Generally with Capybara you configure the server in a register_server block. The :puma server definition Capybara provides is Capybara.register_server :puma do |app, port, host| require 'rack/handler/puma' Rack::Handler::Puma.run(app,