driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
click_on(exact_text: /\w{48}\.txt/)
. Before that I do a "search" in my app which returns one result (the one that must be clicked). But Capybara tells me Ambiguous match, found 38 elements matching visible link or button nil
. This is definitely not correct. There is only one link that has that exact text. If I get the HTML that is produced by the failure and put it in a simple test case, it passes. Capybara does something strange. If I change it to click_on(text: /\w{48}\.txt/)
it works fine. This is using Capybara.exact = false
. Any ideas?
sleep 1
before that, it passes too.
default_max_wait_time
set to a very small value? Workarounds could possibly be click_on(text: /^\w{48}\.txt$/)
or click_on(text: /\w{48}\.txt/, exact_text: true)
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/bridge.rb:57:in `create_session'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:340:in `create_bridge'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:74:in `initialize'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:47:in `new'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:47:in `for'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver.rb:88:in `for'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/capybara-3.36.0/lib/capybara/selenium/driver.rb:83:in `browser'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/capybara-3.36.0/lib/capybara/selenium/driver.rb:104:in `visit'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/capybara-3.36.0/lib/capybara/session.rb:278:in `visit'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/capybara-3.36.0/lib/capybara/dsl.rb:53:in `call'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/capybara-3.36.0/lib/capybara/dsl.rb:53:in `visit'
/home/derrell/RubymineProjects/AliasMadness/features/step_definitions/login.step_definition.rb:22:in `nil'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-7.1.0/lib/cucumber/glue/invoke_in_world.rb:26:in `cucumber_instance_exec_in'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-7.1.0/lib/cucumber/glue/step_definition.rb:133:in `invoke'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-7.1.0/lib/cucumber/step_match.rb:33:in `invoke'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-7.1.0/lib/cucumber/step_match.rb:26:in `block in activate'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-core-10.1.1/lib/cucumber/core/test/action.rb:23:in `execute'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-core-10.1.1/lib/cucumber/core/test/step.rb:35:in `execute'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-core-10.1.1/lib/cucumber/core/test/runner.rb:106:in `execute'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-core-10.1.1/lib/cucumber/core/test/runner.rb:53:in `execute'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-core-10.1.1/lib/cucumber/core/test/runner.rb:29:in `test_step'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-core-10.1.1/lib/cucumber/core/test/step.rb:23:in `describe_to'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-core-10.1.1/lib/cucumber/core/test/case.rb:31:in `block (3 levels) in describe_to'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-core-10.1.1/lib/cucumber/core/test/case.rb:30:in `each'
/home/derrell/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/cucumber-core-10.1.1/lib/cucumber/core/test/case.rb:30:in `block (2 levels) in describe_to'
That's my stack trace. I have numerous errors, and they all start with a Capybara#visit
call. I suspect they're the first such call in each flow (it will take some time to check that, if it's relevant). I have just upgraded gems for ruby 2.7.5 from 2.6.?. Upgrading ruby and just doing bundle install
wasn't enough to trigger this error, but in attempting to push to heroku, I kept having issues with the asset pipeline, and had to upgrade mini_racer, and thus all of the stuff in the test gems to be sure it was working as it would. Now my tests fail, and I am hoping it's just webdriver and not something deep in my code.
This is Rails 6 latest.
find('.foobar').click(x: 120, y: 10)
. When running on Selenium 4.2.1, this code works fine. I do see a warning however - WARN Selenium moving to an element with offset currently tries to use the top left corner of the element as the origin; in Selenium 4.3 it will use the in-view center point of the element as the origin.
- which comes exactly from that line. I guess that is related to the problem?
example.metadata
or example.example_group.before_context_ivars
or something.
have_no_text
isn't defined to work with an array, and I would be shocked if it did. It'll call to_s
on the array and then verify that your page doesn't have whatever that string equivalent of the array is. I also wonder why you'd think what have_no_text
accepts would have any relevance on what have_no_css
accepts?
have_none_of_selectors
- https://rubydoc.info/github/teamcapybara/capybara/Capybara/RSpecMatchers#have_none_of_selectors-instance_method
have_no_text
in the wrong way for a while! :D Thankfully just in one place. have_none_of_selectors
doesn't seem to fit exactly what I need I believe - I want to check that something doesn't contain any of the strings that I pass - for example expect(page).to have_no_text(['foo', 'bar', 'baz'])
- i.e. I want the current scope to not contain either of the three strings. I'm not sure that's possible with have_none_of_selectors
? Perhaps that could be a feature request. :)