I use RoR with cucumber and capybara for tests.
I get strange error whent trying to make right click with capybara:
undefined method `right_click' for #<Capybara::Node::Element:0x0000000930c628> (NoMethodError)
But that class simply should have right_click method, see http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Element#right_click-instance_method
This is the source code
find('a', :text => #name).right_click
If I do some mistake, how to simulate right mouse click properly?
This method is in master only. Neither of released Capybara versions support it.
Related
Using ruby 2.3.0 and rails 4.2.5.1, I'm trying to figure some things
out using the rails console. I have several instances where app or helper seem like they have a method I want, but I often end up with the NoMethodError message. This happens even in a brand-new application where I've edited nothing and given no special options to the rails new command. For instance:
irb(main):015:0* helper.timez
... here I hit TAB to get:
irb(main):015:0* helper.timezone
... and hit ENTER, only to find:
NoMethodError: undefined method `timezone' for #<ActionView::Base:0xc662b80>
Why would tab-expansion in the console expand to methods that don't
exist? More importantly, if they're supposed to be there, why aren't
they? What can I be doing wrong?
I'm currently working on a project using Sorcery to authenticate users and I have some integration tests done with capybara. When I call current_user or logged_in? sorcery helpers I get this error:
ArgumentError Exception: wrong number of arguments calling `page` (0 for 1)
but when I call them in development mode, it doesn't happen.
After some research I found out that the problem comes from find_by_id method. So if I call Model.find_by_id(1), I get this error. I am very confused because I cannot understand why page method is called and where.
I fixed it by overriding the find_by_id method of my model, but I completely disagree doing this way, so...
Does anybody know what's going on?
Thank you in advance guys
I finally fixed it. The problem was that I included Capybara in my env.rb so my ActiveRecord class were inheriting Capybara methods and find_by_id method for finding elements in a webpage was run instead of ActiveRecord find_by_id.
After deleting "include Capybara" line everything works fine.
I am using rails 3.2.16 and ruby 1.9.3
I get this error from the localhost browser after rails s.
undefined method `to_date' for nil:NilClass
like this
NoMethodError in Products#new
Showing /Users/main/railscasts-episodes/episode-350/store-
after/app/views/products/_form.html.erb where line #27 raised:
undefined method `to_date' for nil:NilClass
in irb> mode it works only when I
require 'date'
Now my question is about my rails project. In which file in my project I should add
require 'date'
I added it into my model it did not work. Or, maybe I need to install any specific gem? to make this work
The problem you have isn't an issue with to_date, it's a problem with the object you're trying to perform the method on
Your issue will either be:
You have not declared the variable / object
Your variable / object is not populated with any data
I'd highly recommend posting the controller action you're using to invoke the to_date method. Obviously, there may be an issue with the way you're calling it, but the immediate issue is you're trying to deal with an unpopulated variable
I wish to use the capybara method drag_to in order to manually sort items on a page. Below is my code:
pos2 = find('#first_element')
target = find(#second_element)
pos2.drag_to(target)
However I get the error message:
undefined method `drag_to' for nil:NilClass (NoMethodError)
Am I invoking the method incorrectly? I am attempting to implement as defined here: http://rubydoc.info/gems/capybara/0.4.0/Capybara/Element#drag_to-instance_method
Please note I am able to use other capybara methods fill_in, visit etc without any problems...
Any help would be greatly appreciated!
#drag_to actually won't move sortable elements, since you're not moving it "to" anywhere as much as a set distance in a certain direction. Selenium implements #drag_by but it is not yet supported by Capybara.
See also:
https://github.com/jnicklas/capybara/issues/222
https://github.com/jnicklas/capybara/issues/119
When I run rspec on my rails project I get a very annoying error message, although exact the same code worked before. The only thing I did was adding a new rspec file. Now the new rspec file doesn't contain anything except for "require 'spec_helper'" but I still get this message (and a few others...):
1) Home Page should have 'Lists' and 'Students' links
Failure/Error: visit home_path
NameError:
undefined local variable or method home_path' for > #<RSpec::Core::ExampleGroup::Nested_2:0x00000004c455a0>
# ./spec/requests/homes_spec.rb:5:inblock (2 levels) in '
I have no idea what to do now. Has anyone a clue what's the matter with it?
Thanks
According to your routes proper helper would be home_index_path.
Try to use it.