Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Gustavo Pares
    @gpares
    for capybara i havean iold setting like this
    Ive updated to gem webdrivers and the latest chromedriver as well
    driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
    Thomas Walpole
    @twalpole
    @gpares Look at when you're running the script and what the page status is -- if you want to be able to run that script at any time then just write plain JS which doesn't need JQuery
    or check whether $ exists before using it
    Gustavo Pares
    @gpares
    @twalpole how on earth would I resolve this
    Boris Petrov
    @boris-petrov
    @twalpole - I have in a test 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?
    Also, if I put a sleep 1 before that, it passes too.
    Thomas Walpole
    @twalpole
    @boris-petrov Not 100% sure -- there are some speed optimizations that are done which may be behaving incorrectly here due to the nil selector. Do you have 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)
    Boris Petrov
    @boris-petrov
    No, my default wait time is 10 seconds so it's definitely not small. Thanks for the workarounds! They probably work but is this something you want to take a look into as a fix in Capybara or you don't think it's worth it? Unfortunately I can't seem to be able to create a reproduction. :(
    Thomas Walpole
    @twalpole
    @boris-petrov If you file an issue on the github project I'll get around to looking at it eventually, however without a reproduction it's not going to be a huge priority
    Boris Petrov
    @boris-petrov
    Done!
    Derrell Durrett
    @derrelldurrett
    Howdy! I came here because it was one of about six hits for the error Selenium::WebDriver::Error::WebDriverError: no sessionId in returned payload. You figured that guy's problem out, so I thought maybe you could help me!
    Derrell Durrett
    @derrelldurrett
    
    /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.

    Thomas Walpole
    @twalpole
    @derrelldurrett make sure you’re using the right version of chromedriver for the version of chrome your using , and that you’re using the necessary shim provided by the heroku chrome buildpack
    IITK888
    @IITK888
    Recruit security technicians, high salary, monthly salary can be as high as 50,000 US dollars
    job requirements:
    1. Work experience in security industry
    2. Possess the practical ability of WEB/APP penetration testing
    3. Familiar with security testing tools such as kali linux, awvs, nessus, metasploit, burpsuite, etc., and have a certain understanding of their principles
    4. Familiar with at least one programming language, such as Python, Java, etc.
    5. Familiar with industry security attack and defense trends, track the latest security vulnerabilities, be able to analyze vulnerability principles and implement PoC
    6. Familiar with common web security vulnerabilities, business logic vulnerabilities and their principles in OWASP
    Recruit security technicians, high salary, monthly salary can be as high as 50,000 US dollars
    job requirements:
    1. Work experience in security industry
    2. Possess the practical ability of WEB/APP penetration testing
    3. Familiar with security testing tools such as kali linux, awvs, nessus, metasploit, burpsuite, etc., and have a certain understanding of their principles
    4. Familiar with at least one programming language, such as Python, Java, etc.
    5. Familiar with industry security attack and defense trends, track the latest security vulnerabilities, be able to analyze vulnerability principles and implement PoC
    6. Familiar with common web security vulnerabilities, business logic vulnerabilities and their principles in OWASP
      Contact: Email: zhouchaoxian88gmail.com
    Boris Petrov
    @boris-petrov
    @twalpole it's strange that one can do find('div').double_click but within 'div' { double_click } or within 'div' { page.double_click } don't work. Is it possible to access the "current element" in a within block so I can call double_click on it?
    Thomas Walpole
    @twalpole
    @boris-petrov page.current_scope.double_click
    Boris Petrov
    @boris-petrov
    Ah, OK, thanks.
    raghu bhupatiraju
    @raghuvarmabh
    hello all, anybody know how to replace a text is text box using capybara
    Thomas Walpole
    @twalpole
    @raghuvarmabh What is the element and what have you tried?
    raghu bhupatiraju
    @raghuvarmabh
    the element is a textarea. i think i got it
    in my case the replace text is already selecteed. find_field(class: 'js-ad-bill-message').send_keys("50") worked in replacing just that.
    Thomas Walpole
    @twalpole
    ok -- you should be able to just use fill_in - fill_in(class: 'js-ad-bill-message', with: '50')
    Boris Petrov
    @boris-petrov
    @twalpole I believe Capybara has a bug when used with Selenium 4.3.0. A test of mine started failing after updating Selenium's version. Capybara is the latest. The specific code that is not working right is 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?
    Thomas Walpole
    @twalpole
    @boris-petrov yes if you e updated to a version of Selenium which changes the behavior you’re going to have a problem. Unfortunately selenium doesn’t follow semantic versioning which sometimes makes supporting it difficult - try the master branch of Capybara
    Thomas Walpole
    @twalpole
    and see the history.md file for the setting which controls the offset origin
    Boris Petrov
    @boris-petrov
    Oh, so this has been fixed? Thank you! I'll eagerly await a release then. :)
    I should have checked the changelog before writing here. Sorry about that!
    Thomas Walpole
    @twalpole
    No problem - you may need to change the setting mentioned in the changelog when using the latest
    Boris Petrov
    @boris-petrov
    Yep, I saw that, thanks! Why did you decide to make the other one default? Because W3C's default is that and you want to be consistent?
    Thomas Walpole
    @twalpole
    Exactly
    Boris Petrov
    @boris-petrov
    Is it possible to access the current running example via a Session object (page for example).
    I want to access the example.metadata or example.example_group.before_context_ivars or something.
    Thomas Walpole
    @twalpole
    No. The current example is an RSpec construct. It’s passed to the blocks passed to a number of the RSpec methods (it, let, before, after, etc). If you want to access it later you could store that in an instance variable like anything else you want accessible in other methods
    Boris Petrov
    @boris-petrov
    have_no_text works with an array (have_no_text(['a', 'b', 'c'])) but have_no_css doesn't? Why?
    Thomas Walpole
    @twalpole
    @boris-petrov 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?
    If you want multiple selector support you should look at have_none_of_selectors - https://rubydoc.info/github/teamcapybara/capybara/Capybara/RSpecMatchers#have_none_of_selectors-instance_method
    Boris Petrov
    @boris-petrov
    hm, so I've been using 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. :)
    Linden
    @LindenMikus
    hello, I'm trying to run chrome in docker. Running headless works fine but confused about how I can get it to show a GUI (using x11 server or something else type thing). If anyone has ideas would appreciate
    2 replies
    m g
    @mgraffx
    I am seeing more usage of aria-disabled for elements like buttons and fields, etc. recently. While testing for some_button.disabled?, I get false when the button is disabled via aria-disabled. If the element just has the vanilla disabled attribute, that same element registers as disabled. Is there some setting needed for capybara to handle aria-disabled and treat it as disabled when true? Currently using "3.35.3". Would a newer version handle this? Thanks.
    Thomas Walpole
    @twalpole
    @boris-petrov To test for multiple strings easiest approach is to use a regex have_no_text(/foo|bar/)
    Thomas Walpole
    @twalpole
    or you can do something like expect(page).to ['foo', 'bar'].map { |t| have_no_text(t) }.reduce(:and) - write a helper method to implement the complicated part of that
    1 reply
    @mgraffx aria-disabled doesn't actually disable the button, it's only informational. Therefore disabled? does not take it into account .
    1 reply
    Thomas Walpole
    @twalpole
    Using include will lead to flaky tests due to no retry
    1 reply
    Boris Petrov
    @boris-petrov
    @twalpole could you release a new version of Capybara? :) I'm eagerly awaiting some of the fixes and features. :D
    Gus P
    @staycreativedesign
    @twalpole whatup man!
    Boris Petrov
    @boris-petrov
    I'm trying to test what the currently-dragged-link looks like (by default Chrome just shows the URL however this can be changed). I try to take a screenshot with capybara-screenshot after I've done page.driver.browser.action.move_to(link).click_and_hold.move_to(link, 100, 100).perform (which means the page is in a "dragging" state) but the mouse (and hence what is dragged) is not captured in the screenshot. Any ideas?