Capybara 0.3.9 Bug: Chaining .find to scope doesn't work
The following code doesn't work like expected:
page.find(css_selector).find(other_css_selector)
The second .find will search the whole dom instead of a scope.
Rumor has it this is fixed in Capybara 0.4.1.
Related cards:
"Require group" doesn't work with Ubuntu's default Apache installation
If you want to use Require group $GROUPNAME
on your default Apache installation like this:
<Directory "/var/www/foobar">
Order allow,deny
Allow from all
Options None
AllowOverride all
AuthName "Area 5...
How to: Use git bisect to find bugs and regressions
Git allows you to do a binary search across commits to hunt down the commit that introduced a bug.
Given you are currently on your branch's HEAD that is not working as expected, an example workflow could be:
git bisect start # Start bisectin...
Capybara: How to find a hidden field by its label
To find an input with the type hidden, you need to specify the type hidden
:
find_field('Some label', type: :hidden)
Otherwise you will see an exception :
find_field('Some label')
# => Capybara::ElementNotFound: Unable to ...
Capybara: How to find the focused element
Capybara allows you to filter elements that are focused.
page.find(:fillable_field, focused: true) # Filtering only fillable inputs for performance reasons
page.find(:xpath, '//*', focused: true) # Filter all fields
Legacy approac...
Webmock's hash_including doesn't parse query values to string
Webmocks hash_including
is similar to RSpec::Mocks::ArgumentMatchers#hash_including
. Be aware that hash_including
(webmock v3.0.1) doesn't parse integer values to String.
Without hash including you would say:
uri = URI('http://example....
How to find disabled fields with Capybara
At least Selenium cannot find disabled fields. Unless you find them explicitly:
find_field 'This is disabled', disabled: true
Do not use "find" on Capybara nodes from an array
In a nutshell: Capybara's find
will not work properly on nodes from a list. Don't find
on elements from a list.
Background
Consider this HTML:
<div class="message">
<h2>Hello World</h2>
Lorem ipsum...
</div>
...
Advice: Reduce scopes with joins to simple IN-queries
In theory you can take any scope and extend it with additional joins or conditions. We call this chaining scopes.
In practice chaining becomes problematic when scope chains grow more complex. In particular **having JOINs
in your scope will re...
How to negate scope conditions in Rails
Sometimes you want to find the inverse of an ActiveRecord scope. Depending on what you want to achieve, this is quite easy with Rails 7, and a bit more complicated with Rails 6 and below, or when the inverse scope may contain NULL values. [1]
The...
Don't call #node on a Capybara element
Capybara allows you to select DOM elements, e.g. by using field
, find_field(...)
or field_labeled(...)
:
role_select = field_labeled('Role')
In the example above, role_select
is now a Capybara::Driver::Node
. You can call a [number o...