When I add a wait function to an expect(page).to_have_content statement, I get the following error:
WARNING: ignoring the provided expectation message argument ({:wait=>20}) since it is not a string or a proc.
For reference, here is how my wait statement looks:
When 'I change the language' do
expect(page).to have_content 'Primary Text', wait: 10
first('div[data-testid="SelectLanguage"]').click
first('li[data-testid="SelectLanguage__Select__es"]').click
end
Thanks in advance!
The problem with Rubys optional ()s in method calls is that it allows for unclear/ambiguous statements when passing the output of methods as parameters to other methods. In your
the
wait: 10is actually being passed as the second argument to ‘to’ rather thanhave_contentso it's being interpreted asTo get your desired behavior you need to do
One benefit of using something like
rubocopis that it will flag situations like this for you